bug: lettre error wrong version number when configuring SMTP #118

Open
opened 2026-02-16 12:51:30 -05:00 by yindo · 5 comments
Owner

Originally created by @32cls on GitHub (Sep 26, 2025).

What happened?

Hello,

When trying to self host an instance, with an external SMTP service like Mailsent, I get the following error each time I try to send an email for a password reset:

lettre error: Connection error: error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../ssl/record/ssl3_record.c:354:

I use the following SMTP configuration inside the Revolt.toml file:

[api.smtp]
# Email server configuration for verification
# Defaults to no email verification (host field is empty)
host = "smtp.mailersend.net"
username = "XXX@YYY.mlsender.net"
password = "ZZZ"
from_address = "noreply@YYY.mlsender.net"
reply_to = "noreply@YYY.mlsender.net"
port = 587
use_tls = true
use_starttls = true

I tried to play with both tls and starttls options by setting them to true and false and it only gave me a different error when setting tls to false:

lettre error: permanent error (538): Error: Must issue a STARTTLS command first

Also note that the use_starttls option is not shown on https://github.com/revoltchat/backend/blob/main/crates/core/config/Revolt.toml.

From Mailsent documentation, it says they only support TLS versions 1.2 & 1.3, is Revolt using one of these?

Thank you for your help 🙏

Originally created by @32cls on GitHub (Sep 26, 2025). ### What happened? Hello, When trying to self host an instance, with an external SMTP service like Mailsent, I get the following error each time I try to send an email for a password reset: `lettre error: Connection error: error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../ssl/record/ssl3_record.c:354:` I use the following SMTP configuration inside the Revolt.toml file: ``` [api.smtp] # Email server configuration for verification # Defaults to no email verification (host field is empty) host = "smtp.mailersend.net" username = "XXX@YYY.mlsender.net" password = "ZZZ" from_address = "noreply@YYY.mlsender.net" reply_to = "noreply@YYY.mlsender.net" port = 587 use_tls = true use_starttls = true ``` I tried to play with both tls and starttls options by setting them to true and false and it only gave me a different error when setting tls to false: `lettre error: permanent error (538): Error: Must issue a STARTTLS command first` Also note that the use_starttls option is not shown on https://github.com/revoltchat/backend/blob/main/crates/core/config/Revolt.toml. From Mailsent documentation, it says they only support TLS versions 1.2 & 1.3, is Revolt using one of these? Thank you for your help 🙏
yindo added the bug label 2026-02-16 12:51:30 -05:00
Author
Owner

@insertish commented on GitHub (Sep 26, 2025):

You have both TLS and STARTTLS enabled in your config, use one or the other.
Presumably you want just use_tls to be true and the port being set to the TLS endpoint.

@insertish commented on GitHub (Sep 26, 2025): You have both TLS and STARTTLS enabled in your config, use one or the other. Presumably you want just `use_tls` to be true and the port being set to the TLS endpoint.
Author
Owner

@32cls commented on GitHub (Sep 26, 2025):

I tried with the following configuration as Mailsend states they use STARTTLS and enable only ports 587 and 2525 from their documentation:

[api.smtp]
...
use_tls = false
use_starttls = true

And still get the issue below, I could try to change the SMTP service but I think it should be possible to connect with my current configuration

 ERROR authifier::config::email_verification                            > Failed to send email to [myemail@gmail.com]!
lettre error: permanent error (538): Error: Must issue a STARTTLS command first
 INFO  rocket::server::_                                                > Outcome: Success(500 Internal Server Error)
 INFO  rocket::server::_                                                > Response succeeded.
@32cls commented on GitHub (Sep 26, 2025): I tried with the following configuration as Mailsend states they use STARTTLS and enable only ports 587 and 2525 from their documentation: ``` [api.smtp] ... use_tls = false use_starttls = true ``` And still get the issue below, I could try to change the SMTP service but I think it should be possible to connect with my current configuration ```INFO rocket::server::_ > Matched: (send_password_reset) POST /auth/account/reset_password ERROR authifier::config::email_verification > Failed to send email to [myemail@gmail.com]! lettre error: permanent error (538): Error: Must issue a STARTTLS command first INFO rocket::server::_ > Outcome: Success(500 Internal Server Error) INFO rocket::server::_ > Response succeeded. ```
Author
Owner

@Daniel13850 commented on GitHub (Oct 1, 2025):

I had the same problem and i have found the solution (if your provider supports SMTPS).

You need to use the Port 465 for SMTPS, and then only enable the use_tls option, leave use_starttls disabled.

@Daniel13850 commented on GitHub (Oct 1, 2025): I had the same problem and i have found the solution (if your provider supports SMTPS). You need to use the Port 465 for SMTPS, and then only enable the `use_tls` option, leave `use_starttls` disabled.
Author
Owner

@32cls commented on GitHub (Oct 1, 2025):

I tried using port 465, enabling use_tls and disabling use_starttls, but it seems my provider does not support SMTPS from the documentation I read and also because it gives me the following error trying so:

ERROR authifier::config::email_verification                            > Failed to send email to [myemail]@gmail.com!
lettre error: Connection error: connection timed out

I think Mailsend only supports the usage of starttls, for debugging purposes I tried with a short code I copy pasted from somewhere and it worked:

use lettre::{Message, SmtpTransport, Transport}; 
use lettre::transport::smtp::{authentication::{Credentials}}; 

fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
    // Build an email message using the builder pattern
    let email = Message::builder()
        // Set the sender's name and email address
        .from("support@[my_domain]".parse().unwrap()) 
        // Set the recipient's name and email address
        .to("<[my_email]@gmail.com>".parse().unwrap()) 
        // Set the subject of the email
        .subject("Rust Email") 
        // Set the body content of the email
        .body(String::from("Hello World, this is a test email from Rust!")) 
        .unwrap();

    // Create SMTP client credentials using username and password
    let creds = Credentials::new("[mailsend_username]".to_string(), "[mailsend_password".to_string()); 

    // Open a secure connection to the SMTP server using STARTTLS
    let mailer = SmtpTransport::starttls_relay("smtp.mailersend.net")
        .unwrap()  // Unwrap the Result, panics in case of error
        .credentials(creds)  // Provide the credentials to the transport
        .build();  // Construct the transport

    // Attempt to send the email via the SMTP transport
    match mailer.send(&email) { 
        // If email was sent successfully, print confirmation message
        Ok(_) => println!("Email sent successfully!"), 
        // If there was an error sending the email, print the error
        Err(e) => eprintln!("Could not send email: {:?}", e), 
    }

    Ok(())
} 
@32cls commented on GitHub (Oct 1, 2025): I tried using port 465, enabling `use_tls` and disabling `use_starttls`, but it seems my provider does not support SMTPS from the documentation I read and also because it gives me the following error trying so: ``` ERROR authifier::config::email_verification > Failed to send email to [myemail]@gmail.com! lettre error: Connection error: connection timed out ``` I think Mailsend only supports the usage of starttls, for debugging purposes I tried with a short code I copy pasted from somewhere and it worked: ``` use lettre::{Message, SmtpTransport, Transport}; use lettre::transport::smtp::{authentication::{Credentials}}; fn main() -> std::result::Result<(), Box<dyn std::error::Error>> { // Build an email message using the builder pattern let email = Message::builder() // Set the sender's name and email address .from("support@[my_domain]".parse().unwrap()) // Set the recipient's name and email address .to("<[my_email]@gmail.com>".parse().unwrap()) // Set the subject of the email .subject("Rust Email") // Set the body content of the email .body(String::from("Hello World, this is a test email from Rust!")) .unwrap(); // Create SMTP client credentials using username and password let creds = Credentials::new("[mailsend_username]".to_string(), "[mailsend_password".to_string()); // Open a secure connection to the SMTP server using STARTTLS let mailer = SmtpTransport::starttls_relay("smtp.mailersend.net") .unwrap() // Unwrap the Result, panics in case of error .credentials(creds) // Provide the credentials to the transport .build(); // Construct the transport // Attempt to send the email via the SMTP transport match mailer.send(&email) { // If email was sent successfully, print confirmation message Ok(_) => println!("Email sent successfully!"), // If there was an error sending the email, print the error Err(e) => eprintln!("Could not send email: {:?}", e), } Ok(()) } ```
Author
Owner

@32cls commented on GitHub (Oct 15, 2025):

Benefiting from the rebrand to up my issue

@32cls commented on GitHub (Oct 15, 2025): Benefiting from the rebrand to up my issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: stoatchat/self-hosted#118