pub mod smtp;
pub mod traits;
pub mod types;
pub use traits::*;
pub use types::*;
pub use smtp::*;
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const DEFAULT_SMTP_PORT: u16 = 587;
pub const MAX_ATTACHMENT_SIZE: usize = 25 * 1024 * 1024;
#[derive(thiserror::Error, Debug)]
pub enum EmailError {
#[error("SMTP connection error: {0}")]
SmtpConnection(String),
#[error("SMTP authentication error: {0}")]
SmtpAuth(String),
#[error("SMTP send error: {0}")]
SmtpSend(String),
#[error("Template rendering error: {0}")]
TemplateError(String),
#[error("Invalid email address: {0}")]
InvalidEmail(String),
#[error("Attachment error: {0}")]
AttachmentError(String),
#[error("Configuration error: {0}")]
ConfigError(String),
#[error("Network error: {0}")]
NetworkError(String),
#[error("Email error: {0}")]
Other(String),
}
pub type EmailResult<T> = Result<T, EmailError>;
#[derive(Debug, Clone)]
pub struct EmailConfig {
pub smtp: Option<SmtpConfig>,
pub default_sender: Option<String>,
pub default_reply_to: Option<String>,
pub enable_tracking: bool,
pub max_retries: u32,
pub retry_delay: u64,
}
impl Default for EmailConfig {
fn default() -> Self {
Self {
smtp: None,
default_sender: None,
default_reply_to: None,
enable_tracking: false,
max_retries: 3,
retry_delay: 5,
}
}
}
#[derive(Debug, Clone)]
pub enum EmailProvider {
Smtp,
}
impl EmailProvider {
pub fn name(&self) -> &'static str {
match self {
Self::Smtp => "smtp",
}
}
}