rust_smtp_utils 0.1.0

Reusable SMTP helper crate for Rust (lettre-based) with STARTTLS, timeout, and retry.
Documentation
  • Coverage
  • 0%
    0 out of 12 items documented0 out of 3 items with examples
  • Size
  • Source code size: 39.07 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 626.02 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 30s Average build duration of successful builds.
  • all releases: 30s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Alexandros5880/RUST-SMTP-UTILS
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Alexandros5880

RUST-SMTP-UTILS

Reusable SMTP helper crate for Rust (lettre-based) with STARTTLS, timeout, and retry.

Install

oml [dependencies] rust_smtp_utils = { git = "https://github.com/Alexandros5880/RUST-SMTP-UTILS.git" }

Environment

Set these variables:

  • SMTP_HOST (default: smtp.gmail.com)
  • SMTP_PORT (default: 587)
  • SMTP_USERNAME
  • SMTP_PASSWORD

Usage

` ust use rust_smtp_utils::{SmtpConfig, send_text_email}; use lettre::message::Mailbox;

fn main() -> Result<(), Box> { let config = SmtpConfig::from_env()?;

let from = Mailbox::new(Some("My App".into()), config.username.parse()?);
let to = Mailbox::new(None, "admin@example.com".parse()?);
let reply_to = Mailbox::new(None, "user@example.com".parse()?);

send_text_email(
    &config,
    from,
    to,
    "Contact form".into(),
    "Hello from the website".into(),
    Some(reply_to),
)?;

Ok(())

} `

Notes

  • Uses STARTTLS on port 587.
  • Includes a default timeout (10s) and 2 retries with 500ms delay.
  • From should be the authenticated SMTP user. Use Reply-To for user addresses.

Example

Run:

ash cargo run --example send \n

License

MIT\n