stalwartlabs / mail-send

E-mail delivery library for Rust with DKIM support
https://docs.rs/mail-send/
Apache License 2.0
202 stars 21 forks source link

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: MissingStartTls #10

Closed awol2005ex closed 1 year ago

awol2005ex commented 1 year ago

version: mail-send = "0.3.0"

when not connect to stmp with tls: match SmtpClientBuilder::new(email_host,25) .implicit_tls(false) .credentials((email_username, email_password)) .timeout(Duration::from_secs(3)) .connect() .await .unwrap() .send(message) .await { Ok(_) => println!("Email sent successfully!"), Err(e) => panic!("Could not send email: {:?}", e), }

thread 'main' panicked at 'called Result::unwrap() on an Err value: MissingStartTls',

epompeii commented 1 year ago

I am also having issues with the new version and implicit_tls() with the following error Failed to create TLS connection for email: TLS error: received corrupt message.

I am trying to connect to AWS SES on port 587.

mdecimus commented 1 year ago

thread 'main' panicked at 'called Result::unwrap() on an Err value: MissingStartTls',

@awol2005ex This error is because the server does not seem to support the STARTTLS command and you are using the TLS client builder. If you connect manually using telnet and write

EHLO mydomain.org

do you see STARTTLS listed as a capability? If you don't then you need to use the plain text client builder.

mdecimus commented 1 year ago

I am also having issues with the new version and implicit_tls() with the following error Failed to create TLS connection for email: TLS error: received corrupt message.

I am trying to connect to AWS SES on port 587.

Are you setting implicit tls to false?

awol2005ex commented 1 year ago

I change the code to match SmtpClientBuilder::new(email_host,25) .implicit_tls(false) .credentials((email_username, email_password)) .timeout(Duration::from_secs(3)) .connect_plain() .await .unwrap() .send(message) .await { Ok(_) => println!("Email sent successfully!"), Err(e) => panic!("Could not send email: {:?}", e), }

But error : thread 'main' panicked at 'called Result::unwrap() on an Err value: UnexpectedReply(Response { code: 220, esc: [0, 0, 0], message: " Microsoft ESMTP MAIL Service ready at Wed, 1 Feb 2023 09:22:55 +0800" })', src/main.rs:354:38

The stmp server connect return code is 220 not 200 so go to Err . but 220 is corrent code

mdecimus commented 1 year ago

thread 'main' panicked at 'called Result::unwrap() on an Err value: UnexpectedReply(Response { code: 220, esc: [0, 0, 0], message: " Microsoft ESMTP MAIL Service ready at Wed, 1 Feb 2023 09:22:55 +0800" })', src/main.rs:354:38

There was a bug in the plain text connect which has now been fixed on version 0.3.1.

awol2005ex commented 1 year ago

It's OK after upgrade to version 0.3.1

awol2005ex commented 1 year ago

It's OK after upgrade to version 0.3.1