summaryrefslogtreecommitdiff
path: root/src/mailer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailer.rs')
-rw-r--r--src/mailer.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mailer.rs b/src/mailer.rs
index 18f89b0..7f7ad9f 100644
--- a/src/mailer.rs
+++ b/src/mailer.rs
@@ -21,6 +21,7 @@ impl Mailer {
from: Mailbox,
host: &str,
port: u16,
+ starttls: bool,
verify_base: Absolute<'static>,
) -> anyhow::Result<Self> {
Ok(Mailer {
@@ -28,7 +29,11 @@ impl Mailer {
verify_base,
transport: AsyncSmtpTransport::<Tokio1Executor>::builder_dangerous(host)
.port(port)
- .tls(Tls::Opportunistic(TlsParameters::new(host.to_string())?))
+ .tls(if starttls {
+ Tls::Required(TlsParameters::new(host.to_string())?)
+ } else {
+ Tls::None
+ })
.timeout(Some(Duration::from_secs(5)))
.build(),
})