Sample code for 30+ languages & platforms
Rust

Send email using SSL (port 465).

Send email using SMTP SSL on port 465.

Chilkat Rust Downloads

Rust

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

// The mailman object is used for sending and receiving email.
let mailman = chilkat::MailMan::new();

// Set the SMTP server.
mailman.set_smtp_host("smtp.att.yahoo.com");

// Set SMTP login and password (if necessary)
mailman.set_smtp_username("myUsername@sbcglobal.net");
mailman.set_smtp_password("myPassword");

mailman.set_smtp_ssl(true);
mailman.set_smtp_port(465);

// Create a new email object
let email = chilkat::Email::new();

email.set_subject("This is a test");
email.set_body("This is a test");
email.set_from("Chilkat Support <support@chilkatsoft.com>");
let _ = email.add_to("Chilkat Admin", "admin@chilkatsoft.com").is_ok();

if mailman.send_email(&email).is_err() {
    println!("{}", mailman.last_error_text());
    return;
}

if mailman.close_smtp_connection().is_err() {
    println!("Connection to SMTP server not closed cleanly.");
}

println!("Mail Sent!");