1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! SMTP protocol implementation for RusMES
//!
//! This crate provides a full-featured, RFC 5321-compliant SMTP server
//! implementation built on Tokio for asynchronous I/O.
//!
//! # Features
//!
//! - **RFC 5321 Compliance**: Complete SMTP protocol including HELO/EHLO,
//! MAIL FROM, RCPT TO, DATA, QUIT, RSET, NOOP, and VRFY.
//! - **STARTTLS** (RFC 3207): Opportunistic TLS upgrade for secure transport.
//! - **AUTH** (RFC 4954): Multiple SASL mechanisms:
//! - PLAIN (RFC 4616)
//! - LOGIN
//! - CRAM-MD5 (RFC 2195)
//! - SCRAM-SHA-256 (RFC 5802 / RFC 7677)
//! - **PIPELINING** (RFC 2920): Client-side pipelining support.
//! - **DSN** (RFC 3461): Delivery Status Notification extensions.
//! - **CHUNKING / BDAT** (RFC 3030): Binary data transfer without dot-stuffing.
//! - **SIZE** (RFC 1870): Message size declaration.
//! - **8BITMIME** (RFC 6152): 8-bit MIME content transfer.
//! - **SMTPUTF8** (RFC 6531): Unicode email addresses.
//! - **Submission** (RFC 4409 / RFC 6409): MSA mode on port 587.
//!
//! # Modules
//!
//! - [`auth`]: SASL authentication mechanism implementations.
//! - [`bdat`]: BDAT/CHUNKING extension state machine (RFC 3030).
//! - [`command`]: SMTP command types and parameters.
//! - [`dsn`]: Delivery Status Notification parameter parsing (RFC 3461).
//! - [`parser`]: Nom-based SMTP command parser.
//! - [`response`]: SMTP response code formatting.
//! - [`server`]: Async TCP listener and connection acceptor.
//! - [`session`]: Per-connection state machine and command dispatcher.
//! - [`submission`]: Mail Submission Agent (MSA) server variant.
//!
//! # Quick Start
//!
//! ```no_run
//! use std::sync::Arc;
//! use rusmes_smtp::{SmtpConfig, SmtpServer};
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let config = SmtpConfig {
//! hostname: "mail.example.com".to_string(),
//! max_message_size: 10 * 1024 * 1024, // 10 MiB
//! require_auth: false,
//! enable_starttls: false,
//! ..Default::default()
//! };
//! // Build and run the server (requires auth/storage backends)
//! // let server = SmtpServer::new(config, auth_backend, storage_backend);
//! // server.listen("0.0.0.0:25").await?;
//! Ok(())
//! }
//! ```
use IpNetwork;
use IpAddr;
pub use ;
pub use ;
pub use ;
pub use ;
pub use parse_command;
pub use SmtpResponse;
pub use SmtpServer;
pub use ;
pub use ;
pub use SmtpMailTransport;
/// Check if an IP address is in any of the given CIDR networks
///
/// # Arguments
/// * `ip` - The IP address to check
/// * `networks` - Vector of CIDR network strings (e.g., "192.168.0.0/16")
///
/// # Returns
/// `true` if the IP is in any of the networks, `false` otherwise