From 9317e6b8a559cfa8c4a0da6477fb8f0783230d02 Mon Sep 17 00:00:00 2001 From: remche Date: Fri, 16 Apr 2021 12:33:12 +0200 Subject: [PATCH] allow insecure tls option, second try (#105) --- src/smtp.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/smtp.rs b/src/smtp.rs index b55c9304..c1ac0f97 100644 --- a/src/smtp.rs +++ b/src/smtp.rs @@ -1,11 +1,8 @@ use error_chain::error_chain; -use lettre::{self, - transport::{ - smtp::SmtpTransport, - smtp::client::Tls, - smtp::client::TlsParameters - }, - Transport +use lettre::{ + self, + transport::{smtp::client::Tls, smtp::client::TlsParameters, smtp::SmtpTransport}, + Transport, }; use crate::config::model::Account; @@ -34,7 +31,11 @@ pub fn send(account: &Account, msg: &lettre::Message) -> Result<()> { smtp_relay(&account.smtp_host)? .port(account.smtp_port) - .tls(Tls::Wrapper(tls)) + .tls(if account.smtp_starttls() { + Tls::Required(tls) + } else { + Tls::Wrapper(tls) + }) .credentials(account.smtp_creds()?) .build() .send(msg)?;