Search code examples
asp-classicamazon-web-servicesamazon-sescdo.message

Using amazon SES to send email in classic asp


I'm trying to send a test email with Amazon SES but to no luck:

Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

Const cdoSendUsingPort = 2

With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort 
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "email-smtp.us-east-1.amazonaws.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic 
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "ABCDE"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "12345"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With

With iMsg
Set .Configuration = iConf
.To = "[email protected]"
.From = "[email protected]"
.Subject = "test"
.TextBody = "body"
.Send
End With

response.write("sent")

Logging information seems to suggest something wrong with authentication. Unfortunately, I'm not well versed and don't understand what I might be doing wrong.

Response: 250-email-smtp.amazonaws.com
Response: 250-8BITMIME
Response: 250-SIZE 10485760
Response: 250-STARTTLS
Response: 250-AUTH PLAIN LOGIN
Response: 250 Ok

Command: AUTH LOGIN

Response: 530 Must issue a STARTTLS command first

Command: MAIL FROM: [address in verified senders list]

Response: 530 Authentication required

Command: Quit

Solution

  • The solution is in the following:

    Response: 530 Must issue a STARTTLS command first

    You need to enable a secure connection before you authenticate. You have already enabled SSL through your configuration:

    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    

    Change this to:

    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
    

    (notice the change from True to 1)