Available on crate feature
sendmail-transport
only.Expand description
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 1.x example
use lettre::{
AsyncSendmailTransport, AsyncTransport, Message, SendmailTransport, Tokio1Executor,
};
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
tokio1
orasync-std1
Asynchronously sends emails using thesendmail
command - The Errors that may occur when sending an email over sendmail
- Sends emails using the
sendmail
command