#smtp #tokio #mail #client #mail-server #body #send

yanked tokio-smtp

An SMTP library for Tokio

Uses old Rust 2015

0.3.0 Apr 25, 2018
0.2.0 Feb 23, 2017
0.1.0 Feb 19, 2017

MIT license

57KB
1K SLoC

tokio-smtp

Crate Build Status

Implementation of SMTP for Rust and Tokio.

Documentation


lib.rs:

An SMTP library for Tokio.

The toplevel module exports a basic interface to send mail, through the Mailer type. This interface is hopefully sufficient for the common use case where mail just needs to be delivered to a trusted local mail server or remote mail service.

A low-level client implementation on top of tokio-proto is available in the client module. The server-side is not yet implemented.

Example

extern crate tokio_core;
extern crate tokio_smtp;

use tokio_core::reactor::{Core};
use tokio_smtp::{Mailer};

// In this example, we grab the mail body from a fixture.
const TEST_EML: &'static str = include_str!("fixtures/test.eml");

fn main() {
    // Create the event loop that will drive this server.
    let mut core = Core::new().unwrap();
    let handle = core.handle();

    // Create a mailer that delivers to `localhost:25`.
    let mailer = Mailer::local();

    // Send an email. The `send` method returns an empty future (`()`).
    let return_path = "john@example.test".parse().unwrap();
    let recipient = "alice@example.test".parse().unwrap();
    let body = TEST_EML.to_string();
    let f = mailer.send(return_path, vec![recipient], body, &handle);

    // Start the client on the event loop.
    core.run(f).unwrap();
}

Dependencies

~7–16MB
~173K SLoC