Module melib::smtp[][src]

Expand description

SMTP client support

The connection and methods are async and uses the smol runtime.

Example

extern crate melib;

use melib::futures;
use melib::smol;
use melib::smtp::*;
use melib::Result;
let conf = SmtpServerConf {
    hostname: "smtp.mail.gr".into(),
    port: 587,
    security: SmtpSecurity::StartTLS {
        danger_accept_invalid_certs: false,
    },
    extensions: SmtpExtensionSupport::default(),
    auth: SmtpAuth::Auto {
        username: "l15".into(),
        password: Password::CommandEval(
            "gpg2 --no-tty -q -d ~/.passwords/mail.gpg".into(),
        ),
        require_auth: true,
    },
};

std::thread::Builder::new().spawn(move || {
    let ex = smol::Executor::new();
    futures::executor::block_on(ex.run(futures::future::pending::<()>()));
}).unwrap();

let mut conn = futures::executor::block_on(SmtpConnection::new_connection(conf)).unwrap();
futures::executor::block_on(conn.mail_transaction(r#"To: l10@mail.gr
Subject: Fwd: SMTP TEST
From: Me <l15@mail.gr>
Message-Id: <E1hSjnr-0003fN-RL@pppppp>
Date: Mon, 13 Jul 2020 09:02:15 +0300

Prescriptions-R-X"#,
    b"l15@mail.gr",
    b"l10@mail.gr",
)).unwrap();
Ok(())

Structs

A single line or multi-line server reply, along with its reply code

SMTP client session object.

Configured SMTP extensions to use

Server configuration for connecting the SMTP client

Enums

Source of user’s password for SMTP authentication

Recognized kinds of SMTP reply codes

Kind of server authentication the client should attempt

Kind of server security (StartTLS/TLS/None) the client should attempt

Type Definitions

Expected reply code in a single or multi-line reply by the server