summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rocket.toml6
-rw-r--r--src/lib.rs3
-rw-r--r--src/mailer.rs7
3 files changed, 15 insertions, 1 deletions
diff --git a/Rocket.toml b/Rocket.toml
index 85c5abf..26cc045 100644
--- a/Rocket.toml
+++ b/Rocket.toml
@@ -95,6 +95,12 @@ limits.bytes = "128 KiB"
#
#mail_port = 25
+# mail starttls support (optional)
+#
+# whether or not to use starttls for mail connections.
+#
+#mail_starttls = false
+
# invite only mode (optional)
#
# if set this instance will run in invite-only mode, disabling public
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(),
})