async_smtp/
lib.rs

1//! Async implementation of the SMTP protocol client in Rust.
2//!
3//! This SMTP client follows [RFC 5321](https://tools.ietf.org/html/rfc5321),
4//! and is designed to efficiently send emails from an application to a relay email server,
5//! as it relies as much as possible on the relay server for sanity and RFC compliance checks.
6//!
7//! It implements the following extensions:
8//!
9//! * 8BITMIME ([RFC 6152](https://tools.ietf.org/html/rfc6152))
10//! * AUTH ([RFC 4954](http://tools.ietf.org/html/rfc4954)) with PLAIN, LOGIN and XOAUTH2 mechanisms
11//! * STARTTLS ([RFC 2487](http://tools.ietf.org/html/rfc2487))
12//! * SMTPUTF8 ([RFC 6531](http://tools.ietf.org/html/rfc6531))
13//! * PIPELINING ([RFC 2920](<https://tools.ietf.org/html/rfc2920>))
14
15#![deny(
16    missing_copy_implementations,
17    trivial_casts,
18    trivial_numeric_casts,
19    unsafe_code,
20    unstable_features,
21    unused_import_braces,
22    missing_debug_implementations,
23    missing_docs,
24    clippy::explicit_iter_loop,
25    clippy::unwrap_used,
26    clippy::expect_used,
27    clippy::indexing_slicing,
28    clippy::string_slice
29)]
30
31#[cfg(not(any(feature = "runtime-tokio", feature = "runtime-async-std")))]
32compile_error!("one of 'runtime-async-std' or 'runtime-tokio' features must be enabled");
33
34#[cfg(all(feature = "runtime-tokio", feature = "runtime-async-std"))]
35compile_error!("only one of 'runtime-async-std' or 'runtime-tokio' features must be enabled");
36
37pub mod authentication;
38mod codec;
39pub mod commands;
40pub mod error;
41pub mod extension;
42pub mod response;
43mod smtp_client;
44mod stream;
45mod types;
46pub mod util;
47pub use crate::smtp_client::{SmtpClient, SmtpTransport};
48pub use types::*;
49
50/// Asynchronous test using tokio or async-std depending on the configuration.
51#[cfg(test)]
52#[macro_export]
53macro_rules! async_test {
54    ($name:ident, $block:block) => {
55        #[cfg(feature = "runtime-tokio")]
56        #[tokio::test]
57        async fn $name() {
58            $block
59        }
60
61        #[cfg(feature = "runtime-async-std")]
62        #[async_std::test]
63        async fn $name() {
64            $block
65        }
66    };
67}