Tcl
Tcl
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 Tcl Downloads
load ./chilkat.dll
set success 0
# Assumes Chilkat is unlocked. See Global Unlock Sample.
set success 0
set mail [new_CkMailMan]
# Use the SMTP endpoint and SMTP credentials issued for the same AWS Region.
CkMailMan_put_SmtpHost $mail "email-smtp.us-west-2.amazonaws.com"
CkMailMan_put_SmtpPort $mail 465
CkMailMan_put_SmtpSsl $mail 1
CkMailMan_put_RequireSslCertVerify $mail 1
CkMailMan_put_SmtpUsername $mail "SES_SMTP_USERNAME"
CkMailMan_put_SmtpPassword $mail "SES_SMTP_PASSWORD"
set email [new_CkEmail]
CkEmail_put_From $email "sender+reports@example.com"
CkEmail_put_Subject $email "SES SMTP connection test"
CkEmail_put_Body $email "This message was submitted over implicit TLS on port 465."
set success [CkEmail_AddTo $email "SES mailbox simulator" "success@simulator.amazonses.com"]
if {$success != 1} then {
puts [CkEmail_lastErrorText $email]
delete_CkMailMan $mail
delete_CkEmail $email
exit
}
set success [CkMailMan_SendEmail $mail $email]
if {$success != 1} then {
puts [CkMailMan_lastErrorText $mail]
delete_CkMailMan $mail
delete_CkEmail $email
exit
}
puts "SES accepted the message over SMTP."
set success [CkMailMan_CloseSmtpConnection $mail]
if {$success != 1} then {
# The server already accepted the message. Retrying here could send a duplicate.
puts "The SMTP connection did not close cleanly."
}
delete_CkMailMan $mail
delete_CkEmail $email