SMTP server port configuration #944

Closed
opened 2021-09-02 21:52:35 +00:00 by KitaitiMakoto · 3 comments

Some cloud vendors block port (25 and) 465.

Some cloud vendors block port (25 and) 465.

For that issue, we can add a new environment variable: MAIL_PORT.

Then we add a new helper, based on https://docs.rs/lettre/0.9.6/src/lettre/smtp/mod.rs.html#133-144:

fn new_simple_with_port(domain: &str, port: u16) -> Result<SmtpClient, Error> {
        //Original code from lettre
        let mut tls_builder = TlsConnector::builder();
        tls_builder.min_protocol_version(Some(DEFAULT_TLS_PROTOCOLS[0]));

        let tls_parameters =
            ClientTlsParameters::new(domain.to_string(), tls_builder.build().unwrap());

        SmtpClient::new(
        	//Modified for configuration
            (domain, port),
            //Original code
            ClientSecurity::Wrapper(tls_parameters),
        )
    }

And then our code (https://git.joinplu.me/Plume/Plume/src/branch/main/src/mail.rs#L66) become:

let smtp_port = env::var("MAIL_PORT").ok()?;
let mail = SmtpClient::new_simple_with_port(domain,smtp_port)

But maybe this is more an issue of lettre than plume ?

For that issue, we can add a new *environment variable*: **MAIL_PORT**. Then we add a new helper, based on https://docs.rs/lettre/0.9.6/src/lettre/smtp/mod.rs.html#133-144: ```rust fn new_simple_with_port(domain: &str, port: u16) -> Result<SmtpClient, Error> { //Original code from lettre let mut tls_builder = TlsConnector::builder(); tls_builder.min_protocol_version(Some(DEFAULT_TLS_PROTOCOLS[0])); let tls_parameters = ClientTlsParameters::new(domain.to_string(), tls_builder.build().unwrap()); SmtpClient::new( //Modified for configuration (domain, port), //Original code ClientSecurity::Wrapper(tls_parameters), ) } ``` And then our code (https://git.joinplu.me/Plume/Plume/src/branch/main/src/mail.rs#L66) become: ```rust let smtp_port = env::var("MAIL_PORT").ok()?; let mail = SmtpClient::new_simple_with_port(domain,smtp_port) ``` But maybe this is more an issue of **lettre** than **plume** ?
Author
Owner

Good investigation! Let's add the env var and modify Plume code.

Good investigation! Let's add the env var and modify Plume code.
Marius added the
C: Enhancement
Good first issue
labels 2022-01-02 15:48:29 +00:00
Author
Owner

@Marius Thank you for your investication. It helped me very well!

@Marius Thank you for your investication. It helped me very well!
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Plume/Plume#944
No description provided.