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

Commit af4f19d

Browse files
committed
Skip certificate chain validation when sending emails
This is a workaround for #1996, until lettre fixes the root issue
1 parent b82db7a commit af4f19d

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

crates/email/src/transport.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,30 @@ impl Transport {
7575
) -> Result<Self, lettre::transport::smtp::Error> {
7676
let mut t = match mode {
7777
SmtpMode::Plain => AsyncSmtpTransport::<Tokio1Executor>::builder_dangerous(hostname),
78-
SmtpMode::StartTls => AsyncSmtpTransport::<Tokio1Executor>::starttls_relay(hostname)?,
79-
SmtpMode::Tls => AsyncSmtpTransport::<Tokio1Executor>::relay(hostname)?,
78+
SmtpMode::StartTls => {
79+
let tls_parameters =
80+
lettre::transport::smtp::client::TlsParameters::builder(hostname.to_owned())
81+
.dangerous_accept_invalid_certs(true)
82+
.build()?;
83+
84+
AsyncSmtpTransport::<Tokio1Executor>::builder_dangerous(hostname)
85+
.port(lettre::transport::smtp::SUBMISSION_PORT)
86+
.tls(lettre::transport::smtp::client::Tls::Required(
87+
tls_parameters,
88+
))
89+
}
90+
SmtpMode::Tls => {
91+
let tls_parameters =
92+
lettre::transport::smtp::client::TlsParameters::builder(hostname.to_owned())
93+
.dangerous_accept_invalid_certs(true)
94+
.build()?;
95+
96+
AsyncSmtpTransport::<Tokio1Executor>::builder_dangerous(hostname)
97+
.port(lettre::transport::smtp::SUBMISSIONS_PORT)
98+
.tls(lettre::transport::smtp::client::Tls::Wrapper(
99+
tls_parameters,
100+
))
101+
}
80102
};
81103

82104
if let Some(credentials) = credentials {

0 commit comments

Comments
 (0)