Module sendmail

Source
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::header::ContentType, 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")
    .header(ContentType::TEXT_PLAIN)
    .body(String::from("Be happy!"))?;

let sender = SendmailTransport::new();
sender.send(&email)?;

§Async tokio 1.x example

use lettre::{
    message::header::ContentType, 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")
    .header(ContentType::TEXT_PLAIN)
    .body(String::from("Be happy!"))?;

let sender = AsyncSendmailTransport::<Tokio1Executor>::new();
sender.send(email).await?;

§Async async-std 1.x example

 use lettre::{Message, AsyncTransport, AsyncStd1Executor,message::header::ContentType, 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").header(ContentType::TEXT_PLAIN)
     .body(String::from("Be happy!"))?;

 let sender = AsyncSendmailTransport::<AsyncStd1Executor>::new();
 sender.send(email).await?;

Structs§

AsyncSendmailTransporttokio1 or async-std1
Asynchronously sends emails using the sendmail command
Error
The Errors that may occur when sending an email over sendmail
SendmailTransport
Sends emails using the sendmail command