mirror of
https://github.com/chatmail/relay.git
synced 2026-09-10 01:13:14 +00:00
refactor: Use a custom, minimal SMTP client instead of lettre (#33)
This disables the Nagle's algorithm on re-insertion. Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
This commit is contained in:
committed by
GitHub
parent
8d18b73681
commit
0ee1e9924c
@@ -1,5 +1,4 @@
|
||||
use mailparse::MailAddr;
|
||||
use std::error::Error;
|
||||
|
||||
/// Extracts the first email address found in SMTP command or email header.
|
||||
///
|
||||
@@ -27,29 +26,6 @@ pub fn extract_address(input: &str) -> Option<String> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Formats SMTP error to be able to send it back to postfix.
|
||||
pub fn format_smtp_error(error: lettre::transport::smtp::Error) -> String {
|
||||
if let Some(code) = error.status() {
|
||||
format!(
|
||||
"{} {}",
|
||||
code,
|
||||
error
|
||||
.source()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or("Unknown error".to_string())
|
||||
)
|
||||
} else {
|
||||
// Default to 451, most probably means some internal service error (e.g. milter)
|
||||
format!(
|
||||
"451 {}",
|
||||
error
|
||||
.source()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or("Unknown error".to_string())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user