summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs3
-rw-r--r--src/mailer.rs7
2 files changed, 9 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ba654c0..29f3e08 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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(),
})