Sample code for 30+ languages & platforms
DataFlex

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 DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoMail
    Variant vEmail
    Handle hoEmail
    String sTemp1

    Move False To iSuccess

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

    Move False To iSuccess

    Get Create (RefClass(cComChilkatMailMan)) To hoMail
    If (Not(IsComObjectCreated(hoMail))) Begin
        Send CreateComObject of hoMail
    End
    //  Use the SMTP endpoint and SMTP credentials issued for the same AWS Region.
    Set ComSmtpHost Of hoMail To "email-smtp.us-west-2.amazonaws.com"
    Set ComSmtpPort Of hoMail To 465
    Set ComSmtpSsl Of hoMail To True
    Set ComRequireSslCertVerify Of hoMail To True
    Set ComSmtpUsername Of hoMail To "SES_SMTP_USERNAME"
    Set ComSmtpPassword Of hoMail To "SES_SMTP_PASSWORD"

    Get Create (RefClass(cComChilkatEmail)) To hoEmail
    If (Not(IsComObjectCreated(hoEmail))) Begin
        Send CreateComObject of hoEmail
    End
    Set ComFrom Of hoEmail To "sender+reports@example.com"
    Set ComSubject Of hoEmail To "SES SMTP connection test"
    Set ComBody Of hoEmail To "This message was submitted over implicit TLS on port 465."
    Get ComAddTo Of hoEmail "SES mailbox simulator" "success@simulator.amazonses.com" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get pvComObject of hoEmail to vEmail
    Get ComSendEmail Of hoMail vEmail To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoMail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "SES accepted the message over SMTP."
    Get ComCloseSmtpConnection Of hoMail To iSuccess
    If (iSuccess <> True) Begin
        //  The server already accepted the message. Retrying here could send a duplicate.
        Showln "The SMTP connection did not close cleanly."
    End



End_Procedure