File size: 673 Bytes
b09157d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import nodemailer from 'nodemailer';
import { Resolver } from 'node:dns/promises';
import * as tls from 'node:tls';
export async function createGmailTransport(options) {
// Use IPv4 on workstations with advertised but unusable IPv6 connectivity.
const resolver = new Resolver({ timeout: 5000, tries: 1 });
const [host] = await resolver.resolve4('smtp.gmail.com');
const ca = tls.getCACertificates
? [...tls.getCACertificates('default'), ...tls.getCACertificates('system')]
: tls.rootCertificates;
return nodemailer.createTransport({
...options, host, port: 587, secure: false, requireTLS: true,
tls: { servername: 'smtp.gmail.com', ca },
});
}
|