diff options
author | pennae <github@quasiparticle.net> | 2022-07-18 21:56:40 +0200 |
---|---|---|
committer | pennae <github@quasiparticle.net> | 2022-07-19 00:01:29 +0200 |
commit | 0d5f948b5a5d52de08b65ff1a91132e8a2aa1d33 (patch) | |
tree | 54119f00bc753436d8605dd959ebe3a8c9e00f21 /src | |
parent | 5a8888a1cbe3d9ffab0497ea10ad84def60d8827 (diff) | |
download | minor-skulk-0d5f948b5a5d52de08b65ff1a91132e8a2aa1d33.tar.gz minor-skulk-0d5f948b5a5d52de08b65ff1a91132e8a2aa1d33.tar.xz minor-skulk-0d5f948b5a5d52de08b65ff1a91132e8a2aa1d33.zip |
add mail_starttls parameter, default off
local mail connections are much preferred for this service, and those
needn't be encrypted.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 3 | ||||
-rw-r--r-- | src/mailer.rs | 7 |
2 files changed, 9 insertions, 1 deletions
@@ -71,6 +71,8 @@ struct Config { mail_from: Mailbox, mail_host: Option<String>, mail_port: Option<u16>, + #[serde(default)] + mail_starttls: bool, #[serde(default)] invite_only: bool, @@ -250,6 +252,7 @@ pub async fn build( config.mail_from.clone(), config.mail_host.as_deref().unwrap_or("localhost"), config.mail_port.unwrap_or(25), + config.mail_starttls, config.location.clone(), ) .context("setting up mail notifications")?, 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(), }) |