nodemailer / smtp-server

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

What is options.needsUpgrade designed for, which added in 3.1.0? #175

Closed LongTengDao closed 2 years ago

andris9 commented 2 years ago

If needsUpgrade is true and secure is also true, then SMTPServer runs TLS handshake after the TCP connection has been established and the connection object has been initiated. Otherwise, the TLS handshake is run before everything else.

LongTengDao commented 2 years ago

Does this make any difference?

For example, different policy for early data before tls handshake is done?

I try to read the source, the only difference I can find, is that the options.onConnect callback won't wait secure event emit in needsUpgrade mode.

andris9 commented 2 years ago

This option was added because of ZoneMTA. ZoneMTA does not process SMTP connections normally but actually runs a wrapper around it. ZoneMTA listens for the sockets to be opened and then, if a worker process would be available, would pass that socket to the worker process. ZoneMTA would then call the SMTPServer.connect method directly so that the normal connection handler is bypassed and upgrading TLS would have to be handled separately. https://github.com/zone-eu/zone-mta/blob/b483b3162455ddf5085e43397ca1777b58063700/services/receiver.js#L137

LongTengDao commented 2 years ago

Thank a lot!