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

SOC 2 Manager, Audit and Certification

@ Deloitte | US and CA Multiple Locations

Cloud Security Engineer

@ Gainwell Technologies | Any city, OR, US, 99999

Federal Workday Security Lead

@ Accenture Federal Services | Arlington, VA

Workplace Consultant

@ Solvinity | Den Bosch, Noord-Brabant, Nederland

SrMgr-Global Information Security - Security Risk Management

@ Marriott International | Bethesda, MD, United States

Sr. Security Engineer - Data Loss Prevention

@ Verisk | Jersey City, NJ, United States