nodemailer / smtp-server

Create custom SMTP servers on the fly
Other
846 stars 145 forks source link

Session envelope contents lost after receiving data from same session #184

Closed zefir-git closed 1 year ago

zefir-git commented 1 year ago

I set up my smtp-server to console.log and allow all connect, mail from, rcpt to, auth, data

TLS

openssl s_client -starttls smtp -crlf -connect localhost:587

SMTP

  1. auth login I have callback(null, {user: "test"})
  2. helo test
  3. mail from: <test@example.com> session.envelope is
    { mailFrom: { address: 'test@example.com', args: false }, rcptTo: [] }
  4. rcpt to: <johndoe@example.com> session.envelope is
    {
    mailFrom: { address: 'test@domain.com', args: false },
    rcptTo: [ { address: 'johndoe@domain.com', args: false } ]
    }
  5. data

    To:  John Doe <johndoe@example.com>
    From: Test <test@example.com>
    Subject: Hello world
    
    asd hello
    world
    
    .

    session.envelope is

    { mailFrom: false, rcptTo: [] }

What is the reason for the envelope object to change after receiving data? Should I store its contents before receiving data? What if data is never sent?

andris9 commented 1 year ago

SMTP client can send multiple emails and the session is reset after each data completion

zefir-git commented 1 year ago

SMTP client can send multiple emails and the session is reset after each data completion

what is the best practice to obtain mail from and rcpt to data when data is submitted?

zefir-git commented 1 year ago

@andris9 I have still not figured this out.

Are you certain that when receiving data the envelope should already be cleared? How am I supposed to access the envelope when I receive the data?

Any pointers would be much appreciated.