SMTP mail_transaction triggers odd issue with greenmail #307

Closed
opened 2023-10-02 22:30:09 +03:00 by matzipan · 0 comments

melib version 0.8.2

Code:

extern crate melib;

use melib::futures;
use melib::smol;
use melib::smtp::*;

fn main() {
    let conf = SmtpServerConf {
        hostname: "localhost".into(),
        port: 3025,
        security: SmtpSecurity::None,
        extensions: SmtpExtensionSupport::default(),
        auth: SmtpAuth::None,
        envelope_from: "l123@mail.gr".into(),
    };

    std::thread::Builder::new()
        .spawn(move || {
            let ex = smol::Executor::new();
            futures::executor::block_on(ex.run(futures::future::pending::<()>()));
        })
        .unwrap();

    let mut conn = futures::executor::block_on(SmtpConnection::new_connection(conf)).unwrap();
    futures::executor::block_on(conn.mail_transaction(
        r#"To: l10@mail.gr
Subject: Fwd: SMTP TEST
From: Me <l15@mail.gr>
Message-Id: <E1hSjnr-0003fN-RL@pppppp>
Date: Mon, 13 Jul 2020 09:02:15 +0300

Prescriptions-R-X"#,
        Some(&[melib::Address::new(None, "l15@mail.gr".into())]),
    ))
    .unwrap();
}

Run greenmail:

docker pull greenmail/standalone:2.0.0
docker run -it --rm -e GREENMAIL_OPTS='-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.verbose' -p 3025:3025 -p 3110:3110 -p 3143:3143 -p 3465:3465 -p 3993:3993 -p 3995:3995 -p 8080:8080 greenmail/standalone:2.0.0

The following log will be produced:

2023-10-02 18:49:10,999 DEBUG    util.LineLoggingBuffer| S: 220 /10.0.2.100 GreenMail SMTP Service v2.0.0 ready\r\n
2023-10-02 18:49:10,999 DEBUG    util.LineLoggingBuffer| C: EHLO meli.delivery\r\n
2023-10-02 18:49:10,999 DEBUG    util.LineLoggingBuffer| S: 250-/10.0.2.100\r\n
2023-10-02 18:49:11,000 DEBUG    util.LineLoggingBuffer| S: 250 AUTH PLAIN LOGIN\r\n
2023-10-02 18:49:11,081 DEBUG    util.LineLoggingBuffer| C: MAIL FROM:<l123@mail.gr>\r\n
2023-10-02 18:49:11,082 DEBUG    util.LineLoggingBuffer| S: 250 OK\r\n
2023-10-02 18:49:11,163 DEBUG    util.LineLoggingBuffer| C: RCPT TO:<l15@mail.gr>\r\n
2023-10-02 18:49:11,164 DEBUG    util.LineLoggingBuffer| S: 250 OK\r\n
2023-10-02 18:49:11,246 DEBUG    util.LineLoggingBuffer| C: DATA\r\n
2023-10-02 18:49:11,246 DEBUG    util.LineLoggingBuffer| S: 354 Start mail input; end with <CRLF>.<CRLF>\r\n
2023-10-02 18:49:11,327 DEBUG    util.LineLoggingBuffer| C: To: l10@mail.gr\r\n
2023-10-02 18:49:11,327 DEBUG    util.LineLoggingBuffer| C: Subject: Fwd: SMTP TEST\r\n
2023-10-02 18:49:11,328 DEBUG    util.LineLoggingBuffer| C: From: Me <l15@mail.gr>\r\n
2023-10-02 18:49:11,328 DEBUG    util.LineLoggingBuffer| C: Message-Id: <E1hSjnr-0003fN-RL@pppppp>\r\n
2023-10-02 18:49:11,328 DEBUG    util.LineLoggingBuffer| C: Date: Mon, 13 Jul 2020 09:02:15 +0300\r\n
2023-10-02 18:49:11,328 DEBUG    util.LineLoggingBuffer| C: \r\n
2023-10-02 18:49:11,328 DEBUG    util.LineLoggingBuffer| C: Prescriptions-R-X\r\n
2023-10-02 18:49:11,328 DEBUG    util.LineLoggingBuffer| C: .\r\n
2023-10-02 18:49:11,328 DEBUG    util.LineLoggingBuffer| C: .\r\n
2023-10-02 18:49:11,329 DEBUG    util.LineLoggingBuffer| S: 250 OK\r\n
2023-10-02 18:49:11,329 DEBUG    util.LineLoggingBuffer| S: 500 Invalid command. Must be 4 characters\r\n

If I use python's smtplib I get the following log:

2023-10-02 19:07:22,897 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| S: 220 /10.0.2.100 GreenMail SMTP Service v1.6.8 ready\r\n
2023-10-02 19:07:32,103 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| C: ehlo [192.168.178.53]\r\n
2023-10-02 19:07:32,103 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| S: 250-/10.0.2.100\r\n
2023-10-02 19:07:32,104 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| S: 250 AUTH PLAIN LOGIN\r\n
2023-10-02 19:07:32,104 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| C: mail FROM:<bla@bla.com>\r\n
2023-10-02 19:07:32,115 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| S: 250 OK\r\n
2023-10-02 19:07:32,155 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| C: rcpt TO:<bla@bla.com>\r\n
2023-10-02 19:07:32,156 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| S: 250 OK\r\n
2023-10-02 19:07:32,196 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| C: data\r\n
2023-10-02 19:07:32,197 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| S: 354 Start mail input; end with <CRLF>.<CRLF>\r\n
2023-10-02 19:07:32,238 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| C: Subject: Fwd: SMTP TEST\r\n
2023-10-02 19:07:32,238 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| C: From: Me <l15@mail.gr>\r\n
2023-10-02 19:07:32,239 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| C: Message-Id: <E1hSjnr-0003fN-RL@pppppp>\r\n
2023-10-02 19:07:32,239 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| C: Date: Mon, 13 Jul 2020 09:02:15 +0300\r\n
2023-10-02 19:07:32,239 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| C: Prescriptions-R-X\r\n
2023-10-02 19:07:32,239 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| C: .\r\n
2023-10-02 19:07:32,275 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG    util.LineLoggingBuffer| S: 250 OK\r\n

The reason for this error message is the extra .\r\n at the end. Removing it gets rid of the error.

melib version 0.8.2 Code: ``` extern crate melib; use melib::futures; use melib::smol; use melib::smtp::*; fn main() { let conf = SmtpServerConf { hostname: "localhost".into(), port: 3025, security: SmtpSecurity::None, extensions: SmtpExtensionSupport::default(), auth: SmtpAuth::None, envelope_from: "l123@mail.gr".into(), }; std::thread::Builder::new() .spawn(move || { let ex = smol::Executor::new(); futures::executor::block_on(ex.run(futures::future::pending::<()>())); }) .unwrap(); let mut conn = futures::executor::block_on(SmtpConnection::new_connection(conf)).unwrap(); futures::executor::block_on(conn.mail_transaction( r#"To: l10@mail.gr Subject: Fwd: SMTP TEST From: Me <l15@mail.gr> Message-Id: <E1hSjnr-0003fN-RL@pppppp> Date: Mon, 13 Jul 2020 09:02:15 +0300 Prescriptions-R-X"#, Some(&[melib::Address::new(None, "l15@mail.gr".into())]), )) .unwrap(); } ``` Run greenmail: ``` docker pull greenmail/standalone:2.0.0 docker run -it --rm -e GREENMAIL_OPTS='-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.verbose' -p 3025:3025 -p 3110:3110 -p 3143:3143 -p 3465:3465 -p 3993:3993 -p 3995:3995 -p 8080:8080 greenmail/standalone:2.0.0 ``` The following log will be produced: ``` 2023-10-02 18:49:10,999 DEBUG util.LineLoggingBuffer| S: 220 /10.0.2.100 GreenMail SMTP Service v2.0.0 ready\r\n 2023-10-02 18:49:10,999 DEBUG util.LineLoggingBuffer| C: EHLO meli.delivery\r\n 2023-10-02 18:49:10,999 DEBUG util.LineLoggingBuffer| S: 250-/10.0.2.100\r\n 2023-10-02 18:49:11,000 DEBUG util.LineLoggingBuffer| S: 250 AUTH PLAIN LOGIN\r\n 2023-10-02 18:49:11,081 DEBUG util.LineLoggingBuffer| C: MAIL FROM:<l123@mail.gr>\r\n 2023-10-02 18:49:11,082 DEBUG util.LineLoggingBuffer| S: 250 OK\r\n 2023-10-02 18:49:11,163 DEBUG util.LineLoggingBuffer| C: RCPT TO:<l15@mail.gr>\r\n 2023-10-02 18:49:11,164 DEBUG util.LineLoggingBuffer| S: 250 OK\r\n 2023-10-02 18:49:11,246 DEBUG util.LineLoggingBuffer| C: DATA\r\n 2023-10-02 18:49:11,246 DEBUG util.LineLoggingBuffer| S: 354 Start mail input; end with <CRLF>.<CRLF>\r\n 2023-10-02 18:49:11,327 DEBUG util.LineLoggingBuffer| C: To: l10@mail.gr\r\n 2023-10-02 18:49:11,327 DEBUG util.LineLoggingBuffer| C: Subject: Fwd: SMTP TEST\r\n 2023-10-02 18:49:11,328 DEBUG util.LineLoggingBuffer| C: From: Me <l15@mail.gr>\r\n 2023-10-02 18:49:11,328 DEBUG util.LineLoggingBuffer| C: Message-Id: <E1hSjnr-0003fN-RL@pppppp>\r\n 2023-10-02 18:49:11,328 DEBUG util.LineLoggingBuffer| C: Date: Mon, 13 Jul 2020 09:02:15 +0300\r\n 2023-10-02 18:49:11,328 DEBUG util.LineLoggingBuffer| C: \r\n 2023-10-02 18:49:11,328 DEBUG util.LineLoggingBuffer| C: Prescriptions-R-X\r\n 2023-10-02 18:49:11,328 DEBUG util.LineLoggingBuffer| C: .\r\n 2023-10-02 18:49:11,328 DEBUG util.LineLoggingBuffer| C: .\r\n 2023-10-02 18:49:11,329 DEBUG util.LineLoggingBuffer| S: 250 OK\r\n 2023-10-02 18:49:11,329 DEBUG util.LineLoggingBuffer| S: 500 Invalid command. Must be 4 characters\r\n ``` If I use python's smtplib I get the following log: ``` 2023-10-02 19:07:22,897 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| S: 220 /10.0.2.100 GreenMail SMTP Service v1.6.8 ready\r\n 2023-10-02 19:07:32,103 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| C: ehlo [192.168.178.53]\r\n 2023-10-02 19:07:32,103 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| S: 250-/10.0.2.100\r\n 2023-10-02 19:07:32,104 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| S: 250 AUTH PLAIN LOGIN\r\n 2023-10-02 19:07:32,104 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| C: mail FROM:<bla@bla.com>\r\n 2023-10-02 19:07:32,115 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| S: 250 OK\r\n 2023-10-02 19:07:32,155 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| C: rcpt TO:<bla@bla.com>\r\n 2023-10-02 19:07:32,156 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| S: 250 OK\r\n 2023-10-02 19:07:32,196 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| C: data\r\n 2023-10-02 19:07:32,197 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| S: 354 Start mail input; end with <CRLF>.<CRLF>\r\n 2023-10-02 19:07:32,238 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| C: Subject: Fwd: SMTP TEST\r\n 2023-10-02 19:07:32,238 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| C: From: Me <l15@mail.gr>\r\n 2023-10-02 19:07:32,239 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| C: Message-Id: <E1hSjnr-0003fN-RL@pppppp>\r\n 2023-10-02 19:07:32,239 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| C: Date: Mon, 13 Jul 2020 09:02:15 +0300\r\n 2023-10-02 19:07:32,239 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| C: Prescriptions-R-X\r\n 2023-10-02 19:07:32,239 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| C: .\r\n 2023-10-02 19:07:32,275 smtp:0.0.0.0:3025<-/10.0.2.100:51902 DEBUG util.LineLoggingBuffer| S: 250 OK\r\n ``` The reason for this error message is the extra .\r\n at the end. Removing it gets rid of the error.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 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: meli/meli#307
There is no content yet.