Module lettre::transport::sendmail [−][src]
This is supported on crate feature
sendmail-transport
only.The sendmail transport sends the email using the local sendmail
command.
Sync example
use lettre::{Message, SendmailTransport, Transport}; let email = Message::builder() .from("NoBody <nobody@domain.tld>".parse()?) .reply_to("Yuin <yuin@domain.tld>".parse()?) .to("Hei <hei@domain.tld>".parse()?) .subject("Happy new year") .body(String::from("Be happy!"))?; let sender = SendmailTransport::new(); let result = sender.send(&email); assert!(result.is_ok());
Async tokio 0.2 example
use lettre::{Message, AsyncTransport, Tokio02Executor, AsyncSendmailTransport, SendmailTransport}; let email = Message::builder() .from("NoBody <nobody@domain.tld>".parse()?) .reply_to("Yuin <yuin@domain.tld>".parse()?) .to("Hei <hei@domain.tld>".parse()?) .subject("Happy new year") .body(String::from("Be happy!"))?; let sender = AsyncSendmailTransport::<Tokio02Executor>::new(); let result = sender.send(email).await; assert!(result.is_ok());
Async tokio 1.x example
use lettre::{Message, AsyncTransport, Tokio1Executor, AsyncSendmailTransport, SendmailTransport}; let email = Message::builder() .from("NoBody <nobody@domain.tld>".parse()?) .reply_to("Yuin <yuin@domain.tld>".parse()?) .to("Hei <hei@domain.tld>".parse()?) .subject("Happy new year") .body(String::from("Be happy!"))?; let sender = AsyncSendmailTransport::<Tokio1Executor>::new(); let result = sender.send(email).await; assert!(result.is_ok());
Async async-std 1.x example
use lettre::{Message, AsyncTransport, AsyncStd1Executor, AsyncSendmailTransport}; let email = Message::builder() .from("NoBody <nobody@domain.tld>".parse()?) .reply_to("Yuin <yuin@domain.tld>".parse()?) .to("Hei <hei@domain.tld>".parse()?) .subject("Happy new year") .body(String::from("Be happy!"))?; let sender = AsyncSendmailTransport::<AsyncStd1Executor>::new(); let result = sender.send(email).await; assert!(result.is_ok());
Structs
AsyncSendmailTransport | tokio02 or tokio1 or async-std1 Asynchronously sends emails using the |
Error | The Errors that may occur when sending an email over sendmail |
SendmailTransport | Sends emails using the |