Sample code for 30+ languages & platforms
Xbase++

Amazon SES SMTP: Send email over implicit TLS on port 465

See more Amazon SES Examples

Connect to the regional SES SMTP endpoint with TLS from the start of the connection. Load the SMTP username and password from protected application configuration. SES SMTP passwords are Region-specific and differ from AWS secret access keys used to sign API requests. Replace the From address with a verified sender. The example delivers to the SES mailbox simulator.

TLS connections to SES SMTP · Obtain SMTP credentials

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oMail
LOCAL oEmail

nSuccess := 0

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

nSuccess := 0

oMail := CreateObject("Chilkat.MailMan")
//  Use the SMTP endpoint and SMTP credentials issued for the same AWS Region.
oMail:SmtpHost := "email-smtp.us-west-2.amazonaws.com"
oMail:SmtpPort := 465
oMail:SmtpSsl := 1
oMail:RequireSslCertVerify := 1
oMail:SmtpUsername := "SES_SMTP_USERNAME"
oMail:SmtpPassword := "SES_SMTP_PASSWORD"

oEmail := CreateObject("Chilkat.Email")
oEmail:From := "sender+reports@example.com"
oEmail:Subject := "SES SMTP connection test"
oEmail:Body := "This message was submitted over implicit TLS on port 465."
nSuccess := oEmail:AddTo("SES mailbox simulator", "success@simulator.amazonses.com")
IF (nSuccess != 1)
    ? oEmail:LastErrorText
    oMail:destroy()
    oEmail:destroy()
    RETURN
ENDIF

nSuccess := oMail:SendEmail(oEmail)
IF (nSuccess != 1)
    ? oMail:LastErrorText
    oMail:destroy()
    oEmail:destroy()
    RETURN
ENDIF

? "SES accepted the message over SMTP."
nSuccess := oMail:CloseSmtpConnection()
IF (nSuccess != 1)
    //  The server already accepted the message. Retrying here could send a duplicate.
    ? "The SMTP connection did not close cleanly."
ENDIF

oMail:destroy()
oEmail:destroy()