Avatar of net-workx
net-workx
Flag for United Kingdom of Great Britain and Northern Ireland asked on

ASP CDO with Amazon SES

I am trying to move a script that uses CDO over from using SMTP.com mail relay to using Amazon SES service.

The code was working previously with SMTP, but the configuration of SMTP.com was set to allow all requests from the web server IP that the code is sitting on.  With Amazon SES this isnt possible and you have to authenticate.  SES doesnt allow anything but SSL/TLS connections, hence why i think its failing.

The code is:

Set Mail = CreateObject("CDO.Message")

    Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")= 2
    Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")= "email-smtp.us-east-1.amazonaws.com"
    Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")= 465
    Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
    Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") ="un"
    Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="pw"

    'update the configuration options
    Mail.Configuration.Fields.Update
    
	Mail.From = "info@xxx.com"
	Mail.To = strSendTo
	Mail.Bcc = Bcc
	Mail.Cc = Cc
	Mail.Subject = strSubject 
		IF BodyFormat = 1 THEN
			Mail.TextBody = strMessage
		ELSEIF BodyFormat = 0 THEN
			Mail.HtmlBody = strMessage
		END IF
	Mail.Send
Set Mail = Nothing

Open in new window


If i use the code above, it fails with:


error '80040211'
/pages/processing/process_let_us_contact.asp, line 36

Any idea how i can get ASP classic to work with AWS SES?

I have tried switching to port 25 and the problem is the same.

Thanks,
Carl
AWSASPEmail Protocols

Avatar of undefined
Last Comment
net-workx

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Scott Fell

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Scott Fell

I also  use this site as my reference http://www.paulsadowski.com/wsh/cdo.htm

Another options is to use the aws api http://docs.aws.amazon.com/ses/latest/APIReference/API_SendEmail.html

You can simply use xmlhttppost to send the data
POST / HTTP/1.1
Date: Thu, 18 Aug 2011 22:25:27 GMT
Host: email.us-east-1.amazonaws.com
Content-Type: application/x-www-form-urlencoded
X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE,
 Signature=yXx/wM1bESLuDErJ6HpZg9JK8Gjau7EUe4FWEfmhodo=,
 Algorithm=HmacSHA256, SignedHeaders=Date;Host
Content-Length: 230

AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE
&Action=SendEmail
&Destination.ToAddresses.member.1=allan%40example.com
&Message.Body.Text.Data=body
&Message.Subject.Data=Example&Source=user%40example.com
&Timestamp=2011-08-18T22%3A25%3A27.000Z

Open in new window

Scott Fell

One last option that I have resorted to is to use an sdk that already exits like php.  Then set up a php page to do the work for you as your own web service where you can post data to via classic asp xmlhttpost.  It can be a lot easier than trying to program the long way in classic asp.

https://github.com/aws/aws-sdk-php
http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.Ses.SesClient.html#_sendEmail
$result = $client->sendEmail(array(
    // Source is required
    'Source' => 'string',
    // Destination is required
    'Destination' => array(
        'ToAddresses' => array('string', ... ),
        'CcAddresses' => array('string', ... ),
        'BccAddresses' => array('string', ... ),
    ),
    // Message is required
    'Message' => array(
        // Subject is required
        'Subject' => array(
            // Data is required
            'Data' => 'string',
            'Charset' => 'string',
        ),
        // Body is required
        'Body' => array(
            'Text' => array(
                // Data is required
                'Data' => 'string',
                'Charset' => 'string',
            ),
            'Html' => array(
                // Data is required
                'Data' => 'string',
                'Charset' => 'string',
            ),
        ),
    ),
    'ReplyToAddresses' => array('string', ... ),
    'ReturnPath' => 'string',
));

Open in new window

net-workx

ASKER
Sorry for the delay - accepted this cannot be done natively and switched to mandrill.

thanks
Your help has saved me hundreds of hours of internet surfing.
fblack61