From 4cdb9583e9a9a7fe8df4afd429f584fd88a3e0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= <30625554+n3oney@users.noreply.github.com> Date: Wed, 21 Jun 2023 19:36:42 +0200 Subject: [PATCH] feat: allow overriding smtp_password with the LEMMY_SMTP_PASSWORD env var (#3154) Co-authored-by: Dessalines --- crates/utils/src/email.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/utils/src/email.rs b/crates/utils/src/email.rs index eda8309f8..62cbe3c5e 100644 --- a/crates/utils/src/email.rs +++ b/crates/utils/src/email.rs @@ -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)); }