Module lettre::transport::stub

source ·
Expand description

The stub transport logs message envelopes as well as contents. It can be useful for testing purposes.

§Stub Transport

The stub transport logs message envelopes as well as contents. It can be useful for testing purposes.

§Examples

use lettre::{transport::stub::StubTransport, Message, 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 mut sender = StubTransport::new_ok();
let result = sender.send(&email);
assert!(result.is_ok());
assert_eq!(
    sender.messages(),
    vec![(
        email.envelope().clone(),
        String::from_utf8(email.formatted()).unwrap()
    )],
);

Structs§

  • AsyncStubTransporttokio1 or async-std1
    This transport logs messages and always returns the given response
  • An error returned by the stub transport
  • This transport logs messages and always returns the given response