diff --git a/plume-models/src/config.rs b/plume-models/src/config.rs index b7459f73..cb316d5b 100644 --- a/plume-models/src/config.rs +++ b/plume-models/src/config.rs @@ -1,4 +1,5 @@ use crate::search::TokenizerKind as SearchTokenizer; +use crate::smtp::{SMTP_PORT, SUBMISSIONS_PORT, SUBMISSION_PORT}; use rocket::config::Limits; use rocket::Config as RocketConfig; use std::collections::HashSet; @@ -248,6 +249,7 @@ impl SearchTokenizerConfig { pub struct MailConfig { pub server: String, + pub port: u16, pub helo_name: String, pub username: String, pub password: String, @@ -256,6 +258,14 @@ pub struct MailConfig { fn get_mail_config() -> Option { Some(MailConfig { server: env::var("MAIL_SERVER").ok()?, + port: env::var("MAIL_PORT").map_or(SUBMISSIONS_PORT, |port| match port.as_str() { + "smtp" => SMTP_PORT, + "submissions" => SUBMISSIONS_PORT, + "submission" => SUBMISSION_PORT, + number => number + .parse() + .expect(r#"MAIL_PORT must be "smtp", "submissions", "submission" or an integer."#), + }), helo_name: env::var("MAIL_HELO_NAME").unwrap_or_else(|_| "localhost".to_owned()), username: env::var("MAIL_USER").ok()?, password: env::var("MAIL_PASSWORD").ok()?, diff --git a/plume-models/src/lib.rs b/plume-models/src/lib.rs old mode 100755 new mode 100644 index 16d3a159..408c7613 --- a/plume-models/src/lib.rs +++ b/plume-models/src/lib.rs @@ -16,6 +16,7 @@ extern crate serde_json; #[macro_use] extern crate tantivy; +pub use lettre::smtp; use once_cell::sync::Lazy; use plume_common::activity_pub::{inbox::InboxError, request, sign}; use posts::PostEvent;