diff --git a/README.md b/README.md index 69e28f8..11e1d7a 100644 --- a/README.md +++ b/README.md @@ -71,27 +71,29 @@ use lettre::message::header::ContentType; use lettre::transport::smtp::authentication::Credentials; use lettre::{Message, SmtpTransport, Transport}; -let email = Message::builder() - .from("NoBody ".parse().unwrap()) - .reply_to("Yuin ".parse().unwrap()) - .to("Hei ".parse().unwrap()) - .subject("Happy new year") - .header(ContentType::TEXT_PLAIN) - .body(String::from("Be happy!")) - .unwrap(); +fn main() { + let email = Message::builder() + .from("NoBody ".parse().unwrap()) + .reply_to("Yuin ".parse().unwrap()) + .to("Hei ".parse().unwrap()) + .subject("Happy new year") + .header(ContentType::TEXT_PLAIN) + .body(String::from("Be happy!")) + .unwrap(); -let creds = Credentials::new("smtp_username".to_owned(), "smtp_password".to_owned()); + let creds = Credentials::new("smtp_username".to_owned(), "smtp_password".to_owned()); -// Open a remote connection to gmail -let mailer = SmtpTransport::relay("smtp.gmail.com") - .unwrap() - .credentials(creds) - .build(); + // Open a remote connection to gmail + let mailer = SmtpTransport::relay("smtp.gmail.com") + .unwrap() + .credentials(creds) + .build(); -// Send the email -match mailer.send(&email) { - Ok(_) => println!("Email sent successfully!"), - Err(e) => panic!("Could not send email: {e:?}"), + // Send the email + match mailer.send(&email) { + Ok(_) => println!("Email sent successfully!"), + Err(e) => panic!("Could not send email: {e:?}"), + } } ```