diff --git a/lettre/examples/smtp.rs b/lettre/examples/smtp.rs index 232d0ae..0fbc80e 100644 --- a/lettre/examples/smtp.rs +++ b/lettre/examples/smtp.rs @@ -1,7 +1,6 @@ extern crate lettre; -use lettre::{EmailAddress, EmailTransport, SimpleSendableEmail}; -use lettre::smtp::{SecurityLevel, SmtpTransportBuilder}; +use lettre::{EmailAddress, EmailTransport, SimpleSendableEmail, SecurityLevel, SmtpTransport}; fn main() { let email = SimpleSendableEmail::new( @@ -12,7 +11,7 @@ fn main() { ); // Open a local connection on port 25 - let mut mailer = SmtpTransportBuilder::localhost() + let mut mailer = SmtpTransport::builder_localhost() .unwrap() .security_level(SecurityLevel::Opportunistic) .build(); diff --git a/lettre/src/lib.rs b/lettre/src/lib.rs index b7402f1..4392bfc 100644 --- a/lettre/src/lib.rs +++ b/lettre/src/lib.rs @@ -28,6 +28,14 @@ pub mod sendmail; pub mod stub; #[cfg(feature = "file-transport")] pub mod file; + +pub use smtp::SmtpTransport; +pub use smtp::SecurityLevel; +#[cfg(feature = "file-transport")] +pub use file::FileEmailTransport; +pub use stub::StubEmailTransport; +pub use sendmail::SendmailTransport; + use std::fmt; use std::fmt::{Display, Formatter}; diff --git a/lettre/src/smtp/mod.rs b/lettre/src/smtp/mod.rs index 1c9d71b..ebbe654 100644 --- a/lettre/src/smtp/mod.rs +++ b/lettre/src/smtp/mod.rs @@ -18,9 +18,7 @@ //! This is the most basic example of usage: //! //! ```rust,no_run -//! use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; -//! use lettre::smtp::SmtpTransportBuilder; -//! use lettre::smtp::SecurityLevel; +//! use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport, SecurityLevel}; //! //! let email = SimpleSendableEmail::new( //! EmailAddress::new("user@localhost".to_string()), @@ -31,7 +29,7 @@ //! //! // Open a local connection on port 25 //! let mut mailer = -//! SmtpTransportBuilder::localhost().unwrap().security_level(SecurityLevel::Opportunistic).build(); +//! SmtpTransport::builder_localhost().unwrap().security_level(SecurityLevel::Opportunistic).build(); //! // Send the email //! let result = mailer.send(email); //! @@ -41,11 +39,9 @@ //! #### Complete example //! //! ```rust,no_run -//! use lettre::smtp::{SecurityLevel, SmtpTransport, -//! SmtpTransportBuilder}; //! use lettre::smtp::authentication::{Credentials, Mechanism}; //! use lettre::smtp::SUBMISSION_PORT; -//! use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; +//! use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport, SecurityLevel}; //! use lettre::smtp::extension::ClientId; //! //! let email = SimpleSendableEmail::new( @@ -56,7 +52,7 @@ //! ); //! //! // Connect to a remote server on a custom port -//! let mut mailer = SmtpTransportBuilder::new(("server.tld", +//! let mut mailer = SmtpTransport::builder(("server.tld", //! SUBMISSION_PORT)).unwrap() //! // Set the name sent during EHLO/HELO, default is `localhost` //! .hello_name(ClientId::Domain("my.hostname.tld".to_string())) @@ -225,11 +221,6 @@ impl SmtpTransportBuilder { } } - /// Creates a new local SMTP client to port 25 - pub fn localhost() -> Result { - SmtpTransportBuilder::new(("localhost", SMTP_PORT)) - } - /// Use STARTTLS with a specific context pub fn tls_connector(mut self, tls_context: TlsConnector) -> SmtpTransportBuilder { self.tls_connector = tls_context; @@ -346,6 +337,15 @@ macro_rules! try_smtp ( ); impl SmtpTransport { + /// TODO + pub fn builder(addr: A) -> Result { + SmtpTransportBuilder::new(addr) + } + /// Creates a new local SMTP client to port 25 + pub fn builder_localhost() -> Result { + SmtpTransportBuilder::new(("localhost", SMTP_PORT)) + } + /// Creates a new SMTP client /// /// It does not connect to the server, but only creates the `SmtpTransport` diff --git a/lettre_email/examples/smtp.rs b/lettre_email/examples/smtp.rs index 6c1aca2..8a84d01 100644 --- a/lettre_email/examples/smtp.rs +++ b/lettre_email/examples/smtp.rs @@ -1,8 +1,7 @@ extern crate lettre; extern crate lettre_email; -use lettre::EmailTransport; -use lettre::smtp::SmtpTransportBuilder; +use lettre::{SmtpTransport, EmailTransport}; use lettre_email::email::EmailBuilder; fn main() { @@ -17,7 +16,7 @@ fn main() { .unwrap(); // Open a local connection on port 25 - let mut mailer = SmtpTransportBuilder::localhost().unwrap().build(); + let mut mailer = SmtpTransport::builder_localhost().unwrap().build(); // Send the email let result = mailer.send(email);