Rust
Rust
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 Rust Downloads
// Assumes Chilkat is unlocked. See Global Unlock Sample.
let _ = false;
let mail = chilkat::MailMan::new();
// Use the SMTP endpoint and SMTP credentials issued for the same AWS Region.
mail.set_smtp_host("email-smtp.us-west-2.amazonaws.com");
mail.set_smtp_port(465);
mail.set_smtp_ssl(true);
mail.set_require_ssl_cert_verify(true);
mail.set_smtp_username("SES_SMTP_USERNAME");
mail.set_smtp_password("SES_SMTP_PASSWORD");
let email = chilkat::Email::new();
email.set_from("sender+reports@example.com");
email.set_subject("SES SMTP connection test");
email.set_body("This message was submitted over implicit TLS on port 465.");
if email.add_to("SES mailbox simulator", "success@simulator.amazonses.com").is_err() {
println!("{}", email.last_error_text());
return;
}
if mail.send_email(&email).is_err() {
println!("{}", mail.last_error_text());
return;
}
println!("SES accepted the message over SMTP.");
if mail.close_smtp_connection().is_err() {
// The server already accepted the message. Retrying here could send a duplicate.
println!("The SMTP connection did not close cleanly.");
}