]> Untitled Git - lemmy.git/commitdiff
feat: allow overriding smtp_password with the LEMMY_SMTP_PASSWORD env var (#3154)
authorMichał <30625554+n3oney@users.noreply.github.com>
Wed, 21 Jun 2023 17:36:42 +0000 (19:36 +0200)
committerGitHub <noreply@github.com>
Wed, 21 Jun 2023 17:36:42 +0000 (13:36 -0400)
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
crates/utils/src/email.rs

index eda8309f85f1772af377ba3c06b969c5888a34a6..62cbe3c5e046ad890a352db1eefaed61db221bcd 100644 (file)
@@ -78,7 +78,11 @@ pub fn send_email(
   };
 
   // Set the creds if they exist
-  if let (Some(username), Some(password)) = (email_config.smtp_login, email_config.smtp_password) {
+  let smtp_password = std::env::var("LEMMY_SMTP_PASSWORD")
+    .ok()
+    .or(email_config.smtp_password);
+
+  if let (Some(username), Some(password)) = (email_config.smtp_login, smtp_password) {
     builder = builder.credentials(Credentials::new(username, password));
   }