Repository: lettre/lettre (language: rust)

Issue:
The certificate\'s CN name does not match the passed value
I got the mentioned error while trying the simple code:
```rust
use lettre::{
    ClientSecurity, ClientTlsParameters, EmailAddress, Envelope,
    SendableEmail, SmtpClient, Transport,
};
use lettre::smtp::authentication::{Credentials, Mechanism};
use lettre::smtp::ConnectionReuseParameters;
use native_tls::{Protocol, TlsConnector};

fn main() {
    let email = SendableEmail::new(
        Envelope::new(
            Some(EmailAddress::new("email".to_string()).unwrap()),
            vec![EmailAddress::new("email".to_string()).unwrap()],
        ).unwrap(),
        "message_id".to_string(),
        "Hello world".to_string().into_bytes(),
    );

    let mut tls_builder = TlsConnector::builder();
    tls_builder.min_protocol_version(Some(Protocol::Tlsv10));
    let tls_parameters =
        ClientTlsParameters::new(
            "domain".to_string(),
            tls_builder.build().unwrap()
        );

    let mut mailer = SmtpClient::new(
        ("server", 443), ClientSecurity::Wrapper(tls_parameters)
    ).unwrap()
        .authentication_mechanism(Mechanism::Login)
        .credentials(Credentials::new(
            "user".to_string(), "pswd".to_string()
        ))
        .connection_reuse(ConnectionReuseParameters::ReuseUnlimited)
        .transport();

    let result = mailer.send(email);
    println!("{:?}", result);
   // assert!(result.is_ok());

    mailer.close();
}

```

Note:I'm using Win 10 Pro, that is under domain `xxxksa`, and ower server is `email.xxx.com`, the email is under Microsoft Exchange server.


Discussion / hints:
`"domain"` needs to be the domain that the server’s SSL certificate is issued to. It is used to check if the certificate that is handed to the client matches the domain you want to connect to. In other words: both strings, `"domain"` and `"server"`, in your example should most probably be equal. Besides that, your example works fine for me.

The following command requests the certificate from the server and shows said domain (replace Posteo’s SMTP server that I used as an example here with the domain and port of your server):
`openssl s_client -showcerts -connect posteo.de:465 </dev/null | grep "CN ="`
The documentation of the `domain` field of the `lettre::smtp::client::net::ClientTlsParameters` struct should be improved here. Currently is says “The domain to send during the TLS handshake” which I think is wrong. It should say “The domain name which is expected in the TLS certificate from the server”.
Does this fix your issue?

Fix patch:
diff --git a/lettre/src/smtp/client/net.rs b/lettre/src/smtp/client/net.rs
index 000ec5d6a..18fa84c42 100644
--- a/lettre/src/smtp/client/net.rs
+++ b/lettre/src/smtp/client/net.rs
@@ -12,7 +12,7 @@ use std::time::Duration;
 pub struct ClientTlsParameters {
     /// A connector from `native-tls`
     pub connector: TlsConnector,
-    /// The domain to send during the TLS handshake
+    /// The domain name which is expected in the TLS certificate from the server
     pub domain: String,
 }
 


Test patch: