Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Skip certificate chain validation when sending emails
Browse files Browse the repository at this point in the history
This is a workaround for #1996, until lettre fixes the root issue
  • Loading branch information
sandhose committed Oct 23, 2023
1 parent b82db7a commit af4f19d
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions crates/email/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,30 @@ impl Transport {
) -> Result<Self, lettre::transport::smtp::Error> {
let mut t = match mode {
SmtpMode::Plain => AsyncSmtpTransport::<Tokio1Executor>::builder_dangerous(hostname),
SmtpMode::StartTls => AsyncSmtpTransport::<Tokio1Executor>::starttls_relay(hostname)?,
SmtpMode::Tls => AsyncSmtpTransport::<Tokio1Executor>::relay(hostname)?,
SmtpMode::StartTls => {
let tls_parameters =
lettre::transport::smtp::client::TlsParameters::builder(hostname.to_owned())
.dangerous_accept_invalid_certs(true)
.build()?;

AsyncSmtpTransport::<Tokio1Executor>::builder_dangerous(hostname)
.port(lettre::transport::smtp::SUBMISSION_PORT)
.tls(lettre::transport::smtp::client::Tls::Required(
tls_parameters,
))
}
SmtpMode::Tls => {
let tls_parameters =
lettre::transport::smtp::client::TlsParameters::builder(hostname.to_owned())
.dangerous_accept_invalid_certs(true)
.build()?;

AsyncSmtpTransport::<Tokio1Executor>::builder_dangerous(hostname)
.port(lettre::transport::smtp::SUBMISSIONS_PORT)
.tls(lettre::transport::smtp::client::Tls::Wrapper(
tls_parameters,
))
}
};

if let Some(credentials) = credentials {
Expand Down

0 comments on commit af4f19d

Please sign in to comment.