Rust
Rust
GMail SMTP port 587 with "less secure" Password Authentication
See more SMTP Examples
Send email using GMail's SMTP server on port 587 (SSL via STARTTLS).Chilkat Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let mailman = chilkat::MailMan::new();
// Use the GMail SMTP server
// This example assumes your GMail account allows for "less secure apps" to use
// SMTP username/password authentication.
// For OAuth2 authentication, see GMail SMTP with OAuth2 Authentication
mailman.set_smtp_host("smtp.gmail.com");
mailman.set_smtp_port(587);
mailman.set_start_tls(true);
// Set the SMTP login/password.
mailman.set_smtp_username("chilkat.support");
mailman.set_smtp_password("myPassword");
// 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 <chilkat.support@gmail.com>");
let _ = email.add_to("Chilkat", "support@chilkatsoft.com");
if mailman.send_email(&email).is_err() {
println!("{}", mailman.last_error_text());
return;
}
println!("Email sent.");