From c0b7865896b5c2e348e95e2008e699346076b273 Mon Sep 17 00:00:00 2001
From: Manuel Bleichner <mbleichner@gmail.com>
Date: Thu, 13 Jul 2023 13:10:14 +0200
Subject: [PATCH] Fix wrong SMTP port when TLS is being used (fixes #3574)
 (#3607)

Co-authored-by: Manuel Bleichner <manuel.bleichner@bvu.de>
---
 crates/utils/src/email.rs | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/crates/utils/src/email.rs b/crates/utils/src/email.rs
index 3c8d7a1a..fdff1903 100644
--- a/crates/utils/src/email.rs
+++ b/crates/utils/src/email.rs
@@ -68,12 +68,10 @@ pub async fn send_email(
   // is bad.
 
   // Set the TLS
-  let builder_dangerous = AsyncSmtpTransport::builder_dangerous(smtp_server).port(smtp_port);
-
   let mut builder = match email_config.tls_type.as_str() {
-    "starttls" => AsyncSmtpTransport::starttls_relay(smtp_server)?,
-    "tls" => AsyncSmtpTransport::relay(smtp_server)?,
-    _ => builder_dangerous,
+    "starttls" => AsyncSmtpTransport::starttls_relay(smtp_server)?.port(smtp_port),
+    "tls" => AsyncSmtpTransport::relay(smtp_server)?.port(smtp_port),
+    _ => AsyncSmtpTransport::builder_dangerous(smtp_server).port(smtp_port),
   };
 
   // Set the creds if they exist
-- 
2.44.1