feat(transport-smtp): Use hostname as clientid when available

This commit is contained in:
Alexis Mousset
2017-11-19 22:21:13 +01:00
parent 87d0dbdf70
commit 1936211f8e
3 changed files with 6 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ bufstream = { version = "^0.1", optional = true }
native-tls = { version = "^0.1", optional = true }
base64 = { version = "^0.8", optional = true }
hex = { version = "^0.3", optional = true }
hostname = { version = "^0.1", optional = true }
rust-crypto = { version = "^0.2", optional = true }
serde = { version = "^1.0", optional = true }
serde_json = { version = "^1.0", optional = true }
@@ -35,7 +36,7 @@ unstable = []
serde-impls = ["serde", "serde_derive"]
file-transport = ["serde-impls", "serde_json"]
crammd5-auth = ["rust-crypto", "hex"]
smtp-transport = ["bufstream", "native-tls", "base64", "nom"]
smtp-transport = ["bufstream", "native-tls", "base64", "nom", "hostname"]
sendmail-transport = []
[[example]]

View File

@@ -19,6 +19,8 @@ extern crate base64;
extern crate bufstream;
#[cfg(feature = "smtp-transport")]
extern crate native_tls;
#[cfg(feature = "smtp-transport")]
extern crate hostname;
#[cfg(feature = "file-transport")]
extern crate serde_json;
#[cfg(feature = "serde-impls")]

View File

@@ -106,6 +106,7 @@
use EmailTransport;
use SendableEmail;
use native_tls::TlsConnector;
use hostname::get_hostname;
use smtp::authentication::{Credentials, DEFAULT_ENCRYPTED_MECHANISMS,
DEFAULT_UNENCRYPTED_MECHANISMS, Mechanism};
use smtp::client::Client;
@@ -224,7 +225,7 @@ impl SmtpTransportBuilder {
smtp_utf8: false,
credentials: None,
connection_reuse: ConnectionReuseParameters::NoReuse,
hello_name: ClientId::Domain("localhost".to_string()),
hello_name: ClientId::Domain(get_hostname().unwrap_or("localhost".to_string())),
authentication_mechanism: None,
timeout: Some(Duration::new(60, 0)),
})