normalize email from

This commit is contained in:
Mateusz Gruszczyński
2026-07-27 18:24:42 +02:00
parent 3e4cb910c2
commit cc3b172e56
7 changed files with 57 additions and 14 deletions
+13 -9
View File
@@ -25,7 +25,7 @@ use tracing::{debug, info, warn};
use crate::{
queries,
state::{SharedState, SmtpConfig},
state::{SharedState, SmtpConfig, SmtpSecurity},
};
const MIN_PASSWORD: usize = 8;
@@ -2098,15 +2098,19 @@ async fn send_share_invitation(
}
async fn send_message(smtp: &SmtpConfig, message: Message, label: &str) -> Result<(), AuthError> {
let mut builder = if smtp.port == 465 {
AsyncSmtpTransport::<Tokio1Executor>::relay(&smtp.host)
} else {
AsyncSmtpTransport::<Tokio1Executor>::starttls_relay(&smtp.host)
let mut builder = match smtp.security {
SmtpSecurity::None => AsyncSmtpTransport::<Tokio1Executor>::builder_dangerous(&smtp.host),
SmtpSecurity::StartTls => AsyncSmtpTransport::<Tokio1Executor>::starttls_relay(&smtp.host)
.map_err(|error| {
tracing::error!(error = %error, host = %smtp.host, port = smtp.port, security = ?smtp.security, "invalid SMTP configuration");
AuthError::internal("Invalid SMTP configuration.")
})?,
SmtpSecurity::Tls => AsyncSmtpTransport::<Tokio1Executor>::relay(&smtp.host)
.map_err(|error| {
tracing::error!(error = %error, host = %smtp.host, port = smtp.port, security = ?smtp.security, "invalid SMTP configuration");
AuthError::internal("Invalid SMTP configuration.")
})?,
}
.map_err(|error| {
tracing::error!(error = %error, host = %smtp.host, port = smtp.port, "invalid SMTP configuration");
AuthError::internal("Invalid SMTP configuration.")
})?
.port(smtp.port);
if !smtp.username.is_empty() {