use-email 0.1.0

Feature-gated facade crate for RustUse email primitives
Documentation
use use_email::{address, auth, envelope, header, id, mailto, message, mime, smtp};

#[test]
fn facade_modules_are_available() -> Result<(), Box<dyn std::error::Error>> {
    let mailbox = address::Mailbox::new(Some("Jane Doe"), "jane@example.com")?;
    let subject = header::Subject::new("Hello")?;
    let message_id: id::MessageId = "root@example.com".parse()?;
    let message = message::EmailMessage::plain_text("Hello", "A short note.");
    let envelope = envelope::Envelope::new(envelope::EnvelopeSender::new("bounce@example.com")?)
        .with_recipient(envelope::EnvelopeRecipient::new("jane@example.com")?);
    let uri = mailto::MailtoBuilder::new()
        .to("jane@example.com")?
        .subject("Hello")
        .build();
    let reply = smtp::SmtpReply::new(smtp::SmtpReplyCode::new(250)?, "OK")?;
    let spf_record = auth::spf::SpfRecord::new().with_term(auth::spf::SpfTerm::new(
        auth::spf::SpfQualifier::Fail,
        auth::spf::SpfMechanism::All,
    ));
    let parsed_mime = mime::parse_mime("text/plain; charset=utf-8").expect("mime parses");

    assert_eq!(mailbox.address().to_string(), "jane@example.com");
    assert_eq!(subject.field().to_string(), "Subject: Hello");
    assert_eq!(message_id.to_string(), "<root@example.com>");
    assert_eq!(message.subject(), Some("Hello"));
    assert_eq!(envelope.recipients().len(), 1);
    assert_eq!(uri.to_string(), "mailto:jane@example.com?subject=Hello");
    assert_eq!(reply.to_string(), "250 OK");
    assert_eq!(spf_record.to_string(), "v=spf1 -all");
    assert_eq!(parsed_mime.subtype, "plain");
    Ok(())
}