nodemailer / smtp-server

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

Enabling useXForward option causes rejections #147

Open qualia-karl opened 4 years ago

qualia-karl commented 4 years ago

After adding useXForward: true to server options, we started getting the following error when certain email services send to our server:

C: XFORWARD PROTO=ESMTP HELO=redacted.qualified.domain IDENT=REDACTED SOURCE=REMOTE
XFORWARD HELO name resolved as "0"
S: 250 OK
C: MAIL FROM:<REDACTED> BODY=7BIT
S: 503 Error: send HELO/EHLO first

It looks like this is caused by the following line, where it tries to interpret the HELO as a number, which then later on overrides this.hostNameAppearsAs to a falsey value:

https://github.com/nodemailer/smtp-server/blob/427cb7a2382a74f79fea379fb23bf781625ea112/lib/smtp-connection.js#L1084

AgnisLV commented 2 years ago

Having the same issue when trying to use smtp-server as Postfix before-queue proxy filter:

INFO  [#qsv4dn6ryseenowj] Connection from [127.0.0.1]
DEBUG [#qsv4dn6ryseenowj] S: 220 ip-172-31-45-152 ESMTP
DEBUG [#qsv4dn6ryseenowj] C: EHLO test.domain.mx
DEBUG [#qsv4dn6ryseenowj] S: 250-ip-172-31-45-152 Nice to meet you, [127.0.0.1]
DEBUG [#qsv4dn6ryseenowj] 250-8BITMIME
DEBUG [#qsv4dn6ryseenowj] 250-SMTPUTF8
DEBUG [#qsv4dn6ryseenowj] 250-DSN
DEBUG [#qsv4dn6ryseenowj] 250 XFORWARD NAME ADDR PORT PROTO HELO IDENT SOURCE
DEBUG [#qsv4dn6ryseenowj] C: XFORWARD NAME=smtp.somedomain.com ADDR=111.111.111.111 PORT=34892 HELO=smtp.somedomain.com IDENT=[UNAVAILABLE] PROTO=ESMTP SOURCE=REMOTE
INFO  [#qsv4dn6ryseenowj] XFORWARD hostname resolved as "smtp.somedomain.com"
INFO  [#qsv4dn6ryseenowj] XFORWARD from 111.111.111.111 through 127.0.0.1
INFO  [#qsv4dn6ryseenowj] XFORWARD port resolved as "34892"
INFO  [#qsv4dn6ryseenowj] XFORWARD HELO name resolved as "0"
DEBUG [#qsv4dn6ryseenowj] S: 250 OK
DEBUG [#qsv4dn6ryseenowj] C: MAIL FROM:<user@somedomain.com> SIZE=2571
DEBUG [#qsv4dn6ryseenowj] S: 503 Error: send HELO/EHLO first
DEBUG [#qsv4dn6ryseenowj] C: QUIT
DEBUG [#qsv4dn6ryseenowj] S: 221 Bye
INFO  [#qsv4dn6ryseenowj] Connection closed to smtp.somedomain.com

Probably setting that line to this value = (value || '').toLowerCase(); would fix it.