diff --git a/apps/daedalus_client/.env b/apps/daedalus_client/.env.example similarity index 100% rename from apps/daedalus_client/.env rename to apps/daedalus_client/.env.example diff --git a/apps/labrinth/.env b/apps/labrinth/.env.example similarity index 97% rename from apps/labrinth/.env rename to apps/labrinth/.env.example index 07dc02eec..dfafb0d77 100644 --- a/apps/labrinth/.env +++ b/apps/labrinth/.env.example @@ -81,6 +81,8 @@ TURNSTILE_SECRET=none SMTP_USERNAME=none SMTP_PASSWORD=none SMTP_HOST=none +SMTP_PORT=25 +SMTP_TLS=true SITE_VERIFY_EMAIL_PATH=none SITE_RESET_PASSWORD_PATH=none @@ -105,4 +107,4 @@ STRIPE_WEBHOOK_SECRET=none ADITUDE_API_KEY=none -PYRO_API_KEY=none \ No newline at end of file +PYRO_API_KEY=none diff --git a/apps/labrinth/src/auth/email/mod.rs b/apps/labrinth/src/auth/email/mod.rs index 80c8bb8e1..80c129cc0 100644 --- a/apps/labrinth/src/auth/email/mod.rs +++ b/apps/labrinth/src/auth/email/mod.rs @@ -1,6 +1,7 @@ use lettre::message::header::ContentType; use lettre::message::Mailbox; use lettre::transport::smtp::authentication::Credentials; +use lettre::transport::smtp::client::{Tls, TlsParameters}; use lettre::{Address, Message, SmtpTransport, Transport}; use thiserror::Error; @@ -34,9 +35,20 @@ pub fn send_email_raw( let username = dotenvy::var("SMTP_USERNAME")?; let password = dotenvy::var("SMTP_PASSWORD")?; let host = dotenvy::var("SMTP_HOST")?; + let port = dotenvy::var("SMTP_PORT")?.parse::().unwrap_or(25); let creds = Credentials::new(username, password); + let tls_settings = + if dotenvy::var("SMTP_TLS")?.parse::().unwrap_or(true) { + Tls::Wrapper(TlsParameters::new(host.clone())?) + } else { + Tls::None + }; - let mailer = SmtpTransport::relay(&host)?.credentials(creds).build(); + let mailer = SmtpTransport::relay(&host)? + .port(port) + .tls(tls_settings) + .credentials(creds) + .build(); mailer.send(&email)?; diff --git a/apps/labrinth/src/lib.rs b/apps/labrinth/src/lib.rs index 9bfc70ba5..765e6aead 100644 --- a/apps/labrinth/src/lib.rs +++ b/apps/labrinth/src/lib.rs @@ -455,6 +455,8 @@ pub fn check_env_vars() -> bool { failed |= check_var::("SMTP_USERNAME"); failed |= check_var::("SMTP_PASSWORD"); failed |= check_var::("SMTP_HOST"); + failed |= check_var::("SMTP_PORT"); + failed |= check_var::("SMTP_TLS"); failed |= check_var::("SITE_VERIFY_EMAIL_PATH"); failed |= check_var::("SITE_RESET_PASSWORD_PATH");