Created
March 4, 2023 16:54
-
-
Save andris9/a13d9b327ea81d620ea89926d2097921 to your computer and use it in GitHub Desktop.
Custom DNS resolving with Nodemailer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The following example sets up Nodemailer in a way that it does not perform any DNS resolving on its own | |
const hostname = 'smtp.gmail.com'; | |
const resolved = (await dns.promises.resolve(hostname))[0]; | |
const transporter = nodemailer.createTransport({ | |
host: resolved, // <- IP address of the SMTP server | |
name: 'my.machine.hostname', // <- PTR name of sender's public IP address, ends up in the Recieved: header | |
tls: { | |
servername: hostname, // <- hostname of the SMTP server, needed to verify TLS | |
rejectUnauthorized: true, // <- allow only valid certs | |
minVersion: 'TLSv1.2' // <- allow TLSv1.2+, this matches MTA-STS requirements | |
}, | |
port: 465, | |
secure: true, | |
auth: { | |
user: 'username', | |
pass: 'secret' | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment