aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel García <[email protected]>2020-07-05 01:59:15 +0200
committerDaniel García <[email protected]>2020-07-05 01:59:15 +0200
commit596c9b869185a86d7619024066c80a008102199e (patch)
treebf3913371227de502ba06070a38dd19bb6d5c5a4
parentd4357eb55a9fe6ed5d1c26382b282e0708b83528 (diff)
downloadvaultwarden-596c9b869185a86d7619024066c80a008102199e.tar.gz
vaultwarden-596c9b869185a86d7619024066c80a008102199e.zip
Add option to set name during HELO in email settings
-rw-r--r--Cargo.lock18
-rw-r--r--Cargo.toml2
-rw-r--r--src/config.rs4
-rw-r--r--src/mail.rs6
4 files changed, 28 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 3f592016..1fb64652 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -838,6 +838,17 @@ dependencies = [
]
[[package]]
+name = "hostname"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867"
+dependencies = [
+ "libc",
+ "match_cfg",
+ "winapi 0.3.9",
+]
+
+[[package]]
name = "html5ever"
version = "0.22.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1095,6 +1106,7 @@ checksum = "deaf9b74d40fcb52d0f762eb08e45d5152b4db59d29bb73edd4cac7fe796862c"
dependencies = [
"base64 0.12.3",
"bufstream",
+ "hostname",
"hyperx",
"idna 0.2.0",
"line-wrap",
@@ -1215,6 +1227,12 @@ dependencies = [
]
[[package]]
+name = "match_cfg"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
+
+[[package]]
name = "matches"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 8f5ba60f..51f9ae4f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -92,7 +92,7 @@ num-traits = "0.2.12"
num-derive = "0.3.0"
# Email libraries
-lettre = { version = "0.10.0-alpha.1", features = ["smtp-transport", "builder", "serde", "native-tls"], default-features = false }
+lettre = { version = "0.10.0-alpha.1", features = ["smtp-transport", "builder", "serde", "native-tls", "hostname"], default-features = false }
native-tls = "0.2.4"
# Template library
diff --git a/src/config.rs b/src/config.rs
index 80c2d80f..ec6bf2e4 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -394,7 +394,9 @@ make_config! {
/// Json form auth mechanism |> Defaults for ssl is "Plain" and "Login" and nothing for non-ssl connections. Possible values: ["Plain", "Login", "Xoauth2"]
smtp_auth_mechanism: String, true, option;
/// SMTP connection timeout |> Number of seconds when to stop trying to connect to the SMTP server
- smtp_timeout: u64, true, def, 15;
+ smtp_timeout: u64, true, def, 15;
+ /// Server name sent during HELO |> By default this value should be is on the machine's hostname, but might need to be changed in case it trips some anti-spam filters
+ helo_name: String, true, option;
},
/// Email 2FA Settings
diff --git a/src/mail.rs b/src/mail.rs
index 5cdfc849..c660b674 100644
--- a/src/mail.rs
+++ b/src/mail.rs
@@ -2,6 +2,7 @@ use std::str::FromStr;
use lettre::message::{header, Mailbox, Message, MultiPart, SinglePart};
use lettre::transport::smtp::authentication::{Credentials, Mechanism as SmtpAuthMechanism};
+use lettre::transport::smtp::extension::ClientId;
use lettre::{Address, SmtpTransport, Tls, TlsParameters, Transport};
use native_tls::{Protocol, TlsConnector};
@@ -42,6 +43,11 @@ fn mailer() -> SmtpTransport {
_ => smtp_client,
};
+ let smtp_client = match CONFIG.helo_name() {
+ Some(helo_name) => smtp_client.hello_name(ClientId::new(helo_name)),
+ None => smtp_client,
+ };
+
let smtp_client = match CONFIG.smtp_auth_mechanism() {
Some(mechanism) => {
let correct_mechanism = format!("\"{}\"", crate::util::upcase_first(mechanism.trim_matches('"')));