[−][src]Module melib::smtp
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
Reply | A single line or multi-line server reply, along with its reply code |
SmtpAuthType | |
SmtpConnection | SMTP client session object. |
SmtpExtensionSupport | Configured SMTP extensions to use |
SmtpServerConf | Server configuration for connecting the SMTP client |
Enums
Password | Source of user's password for SMTP authentication |
ReplyCode | Recognized kinds of SMTP reply codes |
SmtpAuth | Kind of server authentication the client should attempt |
SmtpSecurity | Kind of server security (StartTLS/TLS/None) the client should attempt |
Functions
default_dsn | |
false_val | |
read_lines | |
true_val |
Type Definitions
ExpectedReplyCode | Expected reply code in a single or multi-line reply by the server |