PureBasic
PureBasic
SES Send Email using SMTP on Port 465 (TLS)
See more Amazon SES Examples
Demonstrates how to send SES email using the SMTP protocol with an implicit TLS connection on port 465.Chilkat PureBasic Downloads
IncludeFile "CkEmail.pb"
IncludeFile "CkMailMan.pb"
Procedure ChilkatExample()
success.i = 0
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
mailman.i = CkMailMan::ckCreate()
If mailman.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Use your SMTP endpoint from your Amazon SES --> SMTP Settings
CkMailMan::setCkSmtpHost(mailman, "email-smtp.us-west-2.amazonaws.com")
; You need Amazon SES SMTP credentials to access the SES SMTP interface.
; The credentials that you use to send email through the SES SMTP interface are unique to each AWS Region.
; If you use the SES SMTP interface to send email in more than one Region,
; you must generate a set of SMTP credentials for each Region that you plan to use.
; See SES SMTP Credentials
; Use your SMTP username and SMTP password for the SMTP credentials you created..
CkMailMan::setCkSmtpUsername(mailman, "AKIA54PBFR4HUHGCIZDS")
CkMailMan::setCkSmtpPassword(mailman, "BrVsadsAULqtHIaEBqx8Xsug073cGYc0PXBYcj17w4OW")
CkMailMan::setCkSmtpSsl(mailman, 1)
CkMailMan::setCkSmtpPort(mailman, 465)
; Create a new email object
email.i = CkEmail::ckCreate()
If email.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkEmail::setCkSubject(email, "This is a test")
CkEmail::setCkBody(email, "This is a test")
CkEmail::setCkFrom(email, "Chilkat Support <support@chilkatsoft.com>")
success = CkEmail::ckAddTo(email,"Chilkat Admin","admin@chilkatsoft.com")
success = CkMailMan::ckSendEmail(mailman,email)
If success <> 1
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
CkEmail::ckDispose(email)
ProcedureReturn
EndIf
success = CkMailMan::ckCloseSmtpConnection(mailman)
If success <> 1
Debug "Connection to SMTP server not closed cleanly."
EndIf
Debug "Mail Sent!"
CkMailMan::ckDispose(mailman)
CkEmail::ckDispose(email)
ProcedureReturn
EndProcedure