Skip to content

Commit

Permalink
allow insecure tls option, second try (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
remche authored Apr 16, 2021
1 parent dd45b4b commit 9317e6b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/smtp.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)?;
Expand Down

0 comments on commit 9317e6b

Please # to comment.