Struct mail_smtp::ConnectionBuilder
source · pub struct ConnectionBuilder<A, S = DefaultTlsSetup>where
S: SetupTls,
A: Cmd,{ /* private fields */ }
Expand description
Builder for an ConnectionConfig
for a encrypted smtp connection.
Implementations
sourceimpl ConnectionBuilder<Noop, DefaultTlsSetup>
impl ConnectionBuilder<Noop, DefaultTlsSetup>
sourcepub fn new(
host: Domain
) -> Result<ConnectionBuilder<Noop, DefaultTlsSetup>, Error>
pub fn new(
host: Domain
) -> Result<ConnectionBuilder<Noop, DefaultTlsSetup>, Error>
Create a new ConnectionBuilder
based on a domain name/host name.
The used port will be DEFAULT_SMTP_MSA_PORT
i.e. 587.
The used socket address will be generate from using std’s ToSocketAddrs
with the given host and default port (the first address returned by
to_socket_addrs
is used, if there is non an std_io::Error
is generated).
Error
std::net::ToSocketAddrs
is used internally and can cause an
io error, e.g. if it can not resolve an address for the given
host name.
sourcepub fn new_with_port(
host: Domain,
port: u16
) -> Result<ConnectionBuilder<Noop, DefaultTlsSetup>, Error>
pub fn new_with_port(
host: Domain,
port: u16
) -> Result<ConnectionBuilder<Noop, DefaultTlsSetup>, Error>
Create a new ConnectionBuilder
based on a domain name/host name and port.
The used socket address will be generate from using std’s ToSocketAddr
with the given host and the given port.
Error
std::net::ToSocketAddrs
is used internally and can cause an
io error, e.g. if it can not resolve an address for the given
host name.
sourcepub fn new_with_addr(
addr: SocketAddr,
domain: Domain
) -> ConnectionBuilder<Noop, DefaultTlsSetup>
pub fn new_with_addr(
addr: SocketAddr,
domain: Domain
) -> ConnectionBuilder<Noop, DefaultTlsSetup>
Crate a new ConnectionBuilder
based on a ip address, port and domain name.
The domain name is used for Server Name Identification (SNI) and Tls hostname verification (hostname of the server).
sourceimpl<A, S> ConnectionBuilder<A, S>where
S: SetupTls,
A: Cmd,
impl<A, S> ConnectionBuilder<A, S>where
S: SetupTls,
A: Cmd,
sourcepub fn use_tls_setup<S2>(self, setup: S2) -> ConnectionBuilder<A, S2>where
S2: SetupTls,
pub fn use_tls_setup<S2>(self, setup: S2) -> ConnectionBuilder<A, S2>where
S2: SetupTls,
Use a different TlsSetup
implementation.
This can be used if an advanced Tls configuration is needed, e.g. if you want to:
- use client certificate authentication
- change the min/max protocol version
- add a root certificate
- disable sni
- and some crazy stuff like disable hostname verification, or certificate verification
sourcepub fn use_start_tls(self) -> ConnectionBuilder<A, S>
pub fn use_start_tls(self) -> ConnectionBuilder<A, S>
Make the builder use STARTTLS
security when building.
sourcepub fn use_direct_tls(self) -> ConnectionBuilder<A, S>
pub fn use_direct_tls(self) -> ConnectionBuilder<A, S>
Make the builder use direct tls security when building.
This is sometimes known as “wrapped” mode, it used a Tcp/Tls channel for transport instead of a pure Tcp channel.
This often requires a different port as port 587 is reserved for “normal” mail submission (using the STARTTLS command) by RFC 6409.
While direct tls is conform with smtp itself (RFC 5321) part of RFC 6409 which further specifies how the smtp should be used when a user (i.e. a mail program) wants to submit a mail to an Mail Submission Agent (MSA).
sourcepub fn auth<NA>(self, auth_cmd: NA) -> ConnectionBuilder<NA, S>where
NA: Cmd,
pub fn auth<NA>(self, auth_cmd: NA) -> ConnectionBuilder<NA, S>where
NA: Cmd,
Set the command to use for authentication.
If this function is not called Noop
is used,
i.e. no authentication is done.
sourcepub fn client_id(self, id: ClientId) -> ConnectionBuilder<A, S>
pub fn client_id(self, id: ClientId) -> ConnectionBuilder<A, S>
Set’s the client identity to the given identity.
(The default is to use ClientId::hostname()
)
sourcepub fn build(self) -> ConnectionConfig<A, S>
pub fn build(self) -> ConnectionConfig<A, S>
Creates a new connection config.
If not specified differently, then
ClientId::hostname()
is used asClientId
Noop
is used as authentication command, i.e. no auth is doneStartTls
is used as security methodDefaultTlsSetup
is used for setting up tls (i.e. no special options are set)
sourcepub fn connect(
self
) -> impl Future<Item = Connection, Error = ConnectingFailed> + Send
pub fn connect(
self
) -> impl Future<Item = Connection, Error = ConnectingFailed> + Send
Calls Connection::connect(self.build())
.