March 30, 2024, 12:44 a.m. | Željko Šević

DEV Community dev.to

To send e-mails in a production environment, use services like Sendgrid.


Verify the e-mail address on the Sender Management page and create the SendGrid API key on the API keys page.



import nodemailer from 'nodemailer';

(async () => {
const emailConfiguration = {
auth: {
user: process.env.EMAIL_USERNAME, // 'apikey'
pass: process.env.EMAIL_PASSWORD
},
host: process.env.EMAIL_HOST, // 'smtp.sendgrid.net'
port: process.env.EMAIL_PORT, // 465
secure: process.env.EMAIL_SECURE, // true
};

const transport = nodemailer.createTransport(emailConfiguration);

const info = await transport.sendMail({
from: '"Sender" <sender@example.com>',
to: …

address api api keys async auth e-mail env environment host import key keys mail mails management .net node page pass process production send sendgrid services smtp verify

CyberSOC Technical Lead

@ Integrity360 | Sandyford, Dublin, Ireland

Cyber Security Strategy Consultant

@ Capco | New York City

Cyber Security Senior Consultant

@ Capco | Chicago, IL

Sr. Product Manager

@ MixMode | Remote, US

Corporate Intern - Information Security (Year Round)

@ Associated Bank | US WI Remote

Senior Offensive Security Engineer

@ CoStar Group | US-DC Washington, DC