Better document that SmtpTransport::builder shouldn't be used
This commit is contained in:
@@ -277,21 +277,6 @@ impl Transport for SmtpTransport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SmtpTransport {
|
impl SmtpTransport {
|
||||||
/// Creates a new SMTP client
|
|
||||||
///
|
|
||||||
/// Defaults are:
|
|
||||||
///
|
|
||||||
/// * No authentication
|
|
||||||
/// * A 60 seconds timeout for smtp commands
|
|
||||||
/// * Port 587
|
|
||||||
///
|
|
||||||
/// Consider using [`SmtpTransport::relay`] instead, if possible.
|
|
||||||
pub fn builder<T: Into<String>>(server: T) -> SmtpTransportBuilder {
|
|
||||||
let mut new = SmtpInfo::default();
|
|
||||||
new.server = server.into();
|
|
||||||
SmtpTransportBuilder { info: new }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Simple and secure transport, should be used when possible.
|
/// Simple and secure transport, should be used when possible.
|
||||||
/// Creates an encrypted transport over submissions port, using the provided domain
|
/// Creates an encrypted transport over submissions port, using the provided domain
|
||||||
/// to validate TLS certificates.
|
/// to validate TLS certificates.
|
||||||
@@ -311,7 +296,7 @@ impl SmtpTransport {
|
|||||||
#[cfg(feature = "rustls-tls")]
|
#[cfg(feature = "rustls-tls")]
|
||||||
let tls_parameters = TlsParameters::new(relay.to_string(), tls);
|
let tls_parameters = TlsParameters::new(relay.to_string(), tls);
|
||||||
|
|
||||||
Ok(Self::builder(relay)
|
Ok(Self::builder_dangerous(relay)
|
||||||
.port(SUBMISSIONS_PORT)
|
.port(SUBMISSIONS_PORT)
|
||||||
.tls(Tls::Wrapper(tls_parameters)))
|
.tls(Tls::Wrapper(tls_parameters)))
|
||||||
}
|
}
|
||||||
@@ -320,7 +305,23 @@ impl SmtpTransport {
|
|||||||
///
|
///
|
||||||
/// Shortcut for local unencrypted relay (typical local email daemon that will handle relaying)
|
/// Shortcut for local unencrypted relay (typical local email daemon that will handle relaying)
|
||||||
pub fn unencrypted_localhost() -> SmtpTransport {
|
pub fn unencrypted_localhost() -> SmtpTransport {
|
||||||
Self::builder("localhost").port(SMTP_PORT).build()
|
Self::builder_dangerous("localhost").build()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a new SMTP client
|
||||||
|
///
|
||||||
|
/// Defaults are:
|
||||||
|
///
|
||||||
|
/// * No authentication
|
||||||
|
/// * No TLS
|
||||||
|
/// * A 60 seconds timeout for smtp commands
|
||||||
|
/// * Port 25
|
||||||
|
///
|
||||||
|
/// Consider using [`SmtpTransport::relay`] instead, if possible.
|
||||||
|
pub fn builder_dangerous<T: Into<String>>(server: T) -> SmtpTransportBuilder {
|
||||||
|
let mut new = SmtpInfo::default();
|
||||||
|
new.server = server.into();
|
||||||
|
SmtpTransportBuilder { info: new }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +349,7 @@ impl Default for SmtpInfo {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
server: "localhost".to_string(),
|
server: "localhost".to_string(),
|
||||||
port: SUBMISSION_PORT,
|
port: SMTP_PORT,
|
||||||
hello_name: ClientId::hostname(),
|
hello_name: ClientId::hostname(),
|
||||||
credentials: None,
|
credentials: None,
|
||||||
authentication: DEFAULT_MECHANISMS.into(),
|
authentication: DEFAULT_MECHANISMS.into(),
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ mod test {
|
|||||||
.subject("Happy new year")
|
.subject("Happy new year")
|
||||||
.body("Be happy!")
|
.body("Be happy!")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
SmtpTransport::builder("127.0.0.1")
|
SmtpTransport::builder_dangerous("127.0.0.1")
|
||||||
.port(2525)
|
.port(2525)
|
||||||
.build()
|
.build()
|
||||||
.send(&email)
|
.send(&email)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn send_one() {
|
fn send_one() {
|
||||||
let pool = Pool::builder().max_size(1);
|
let pool = Pool::builder().max_size(1);
|
||||||
let mailer = SmtpTransport::builder("127.0.0.1")
|
let mailer = SmtpTransport::builder_dangerous("127.0.0.1")
|
||||||
.port(2525)
|
.port(2525)
|
||||||
.build_with_pool(pool);
|
.build_with_pool(pool);
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ mod test {
|
|||||||
fn send_from_thread() {
|
fn send_from_thread() {
|
||||||
let pool = Pool::builder().max_size(1);
|
let pool = Pool::builder().max_size(1);
|
||||||
|
|
||||||
let mailer = SmtpTransport::builder("127.0.0.1")
|
let mailer = SmtpTransport::builder_dangerous("127.0.0.1")
|
||||||
.port(2525)
|
.port(2525)
|
||||||
.build_with_pool(pool);
|
.build_with_pool(pool);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user