Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodemailer #101

Closed
wants to merge 2 commits into from
Closed

Nodemailer #101

wants to merge 2 commits into from

Conversation

trasherdk
Copy link

The transport.verify().then().catch() thing failing 100% even after successful connection to mail server.
Changing to verify((error, success) => {}) fixed that.

nodemailer.createTransport(options); has an option to control if TLS is required or
if STARTTLS should be tried.

Added SMTP_SECURE option to .env

This is what verify() looks like on the mail server: (followed by what the firewall thinks of things)

: NOQUEUE: connect from client.example.com [1.2.3.144]
: AUTH: available mech=PLAIN, allowed mech=EXTERNAL GSSAPI KERBEROS_V4 DIGEST-MD5 CRAM-MD5
: 13QGhgnj025999: Milter (smf-grey): init success to negotiate
: 13QGhgnj025999: Milter (clamav-milter): init success to negotiate
: 13QGhgnj025999: Milter (smf-spamd): init success to negotiate
: 13QGhgnj025999: Milter: connect to filters
: 13QGhgnj025999: milter=smf-grey, action=connect, accepted
: 13QGhgnj025999: milter=clamav-milter, action=connect, continue
: 13QGhgnj025999: milter=smf-spamd, action=connect, continue
: 13QGhgnj025999: --- 220 mail.example.com ESMTP Sendmail 8.15.2/8.15.2; Mon, 26 Apr 2021 18:43:42 +0200
: 13QGhgnj025999: <-- EHLO [127.0.0.1]
: 13QGhgnj025999: milter=smf-spamd, action=helo, continue
: 13QGhgnj025999: --- 250-mail.example.com Hello client.example.com [1.2.3.144], pleased to meet you
: 13QGhgnj025999: --- 250-ENHANCEDSTATUSCODES
: 13QGhgnj025999: --- 250-PIPELINING
: 13QGhgnj025999: --- 250-8BITMIME
: 13QGhgnj025999: --- 250-SIZE
: 13QGhgnj025999: --- 250-DSN
: 13QGhgnj025999: --- 250-ETRN
: 13QGhgnj025999: --- 250-STARTTLS
: 13QGhgnj025999: --- 250-DELIVERBY
: 13QGhgnj025999: --- 250 HELP
: 13QGhgnj025999: <-- STARTTLS
: 13QGhgnj025999: --- 220 2.0.0 Ready to start TLS
: STARTTLS: x509 cert verify: depth=0 /C=DK/ST=Denmark/L=Copenhagen/O=Example/OU=Mailserver Cert/CN=mail.example.com/emailAddress=hostmaster@example.com, state=0, reason=unable to get certificate CRL
: STARTTLS: x509 cert verify: depth=1 /C=DK/ST=Denmark/L=Copenhagen/O=Example Corp/OU=Certification Services Division/CN=Example Corp Root CA/emailAddress=hostmaster@example.com, state=0, reason=unable to get certificate CRL
: STARTTLS=server, get_verify: 0 get_peer: 0x0
: STARTTLS=server, relay=client.example.com [1.2.3.144], version=TLSv1.2, verify=NO, cipher=DHE-RSA-AES128-GCM-SHA256, bits=128/128
: STARTTLS=server, cert-subject=, cert-issuer=, verifymsg=ok
: AUTH: available mech=PLAIN, allowed mech=EXTERNAL GSSAPI KERBEROS_V4 DIGEST-MD5 CRAM-MD5
: STARTTLS=read, info: fds=9/3, err=2
: 13QGhgnj025999: --- 421 4.4.1 mail.example.com Lost input channel from client.example.com [1.2.3.144]
: 13QGhgnj025999: client.example.com [1.2.3.144] did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA

The firewall does not like the way nodemailer behaves, but this connecting client is whitelisted

: Enter dbcheckwhitelist: 1.2.3.144 
: Blacklist IP: 1.2.3.144 - MAIL/EXPN/VRFY/ETRN 
: Enter dbblacklist: 1.2.3.144 - MAIL/EXPN/VRFY/ETRN 
: LOCALNET: Whitelisted host at 1.2.3.144 -- NOT BLACKLISTING 

.env.example Show resolved Hide resolved
src/services/email.service.js Outdated Show resolved Hide resolved
@trasherdk
Copy link
Author

A refactored version, reverting to verify().then().catch() chaining, by adding the missing tls.rejectUnauthorized setting.

Copy link
Owner

@hagopj13 hagopj13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR. And sorry for the late review, I was really busy these days, but now I'm back to occasionally working on the boilerplate.

Please see the minor changes that I requested. Also, can you solve merge conflicts and remove the package-lock.json (we're using yarn.lock)?

.env.example Outdated Show resolved Hide resolved
src/config/config.js Outdated Show resolved Hide resolved
src/services/email.service.js Outdated Show resolved Hide resolved
src/services/email.service.js Outdated Show resolved Hide resolved
@trasherdk
Copy link
Author

Latest push only contain the changes in functionality.
I don't use yarn, so it's capabilities are unknown to me. npm on the other hand, is capable of updating yarn.lock,
keeping both lock files in sync.

@trasherdk trasherdk closed this by deleting the head repository May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants