1 parent
a238ff5e23
commit
93762fe9ef
65 files changed
+5420
-2792
No files matched your search
+13
-1
@@ -128,6 +128,7 @@ pub async fn send_message_handler(
|
||||
host: session.smtp_host.clone(),
|
||||
port: session.smtp_port,
|
||||
tls: session.smtp_tls,
|
||||
tls_verify: session.smtp_tls_verify,
|
||||
email: session.email.clone(),
|
||||
password: session.password.clone(),
|
||||
};
|
||||
@@ -302,6 +303,7 @@ pub async fn send_message_handler(
|
||||
.map_err(AppError::InternalError)?,
|
||||
attachments,
|
||||
pgp,
|
||||
max_message_size_bytes: config.max_message_size_bytes(),
|
||||
};
|
||||
|
||||
// Send via SMTP. The exact RFC822 bytes returned here are also appended
|
||||
@@ -309,7 +311,16 @@ pub async fn send_message_handler(
|
||||
let sent = smtp_client
|
||||
.send_message(&smtp_creds, &message)
|
||||
.await
|
||||
.map_err(|e| AppError::ServiceUnavailable(format!("Failed to send email: {e}")))?;
|
||||
.map_err(|e| match e {
|
||||
crate::smtp::client::SmtpError::MessageTooLarge { actual, limit } => {
|
||||
AppError::PayloadTooLarge(format!(
|
||||
"Message is {:.2} MiB after MIME encoding; configured limit is {:.2} MiB",
|
||||
actual as f64 / 1024.0 / 1024.0,
|
||||
limit as f64 / 1024.0 / 1024.0
|
||||
))
|
||||
}
|
||||
other => AppError::ServiceUnavailable(format!("Failed to send email: {other}")),
|
||||
})?;
|
||||
let message_id = sent.message_id.clone();
|
||||
|
||||
// Best-effort: append a copy to the "Sent" folder via the account's IMAP server.
|
||||
@@ -318,6 +329,7 @@ pub async fn send_message_handler(
|
||||
host: session.imap_host.clone(),
|
||||
port: session.imap_port,
|
||||
tls: session.imap_tls,
|
||||
tls_verify: session.imap_tls_verify,
|
||||
email: session.email.clone(),
|
||||
password: session.password.clone(),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user