Created
January 24, 2024 07:54
-
-
Save Maxim-Kolmogorov/ff92be8065318092d561eb0f58b79780 to your computer and use it in GitHub Desktop.
Send Email with Nodemailer.
This file contains 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
import nodemailer from 'nodemailer' | |
const transporter = nodemailer.createTransport({ | |
service: 'gmail', | |
auth: { | |
user: '[email protected]', | |
pass: 'pass' | |
} | |
}) | |
const mailOptions = { | |
from: '[email protected]', | |
to: '[email protected]', | |
subject: 'Hello World!', | |
html: ` | |
<h1>Hello?</h1> | |
<p>How are you?</p> | |
` | |
} | |
const send = () => { | |
return new Promise((resolve, reject) => { | |
transporter.sendMail(mailOptions, (error, info) => { | |
if (error) { | |
reject(error) | |
} | |
resolve(info) | |
}) | |
}) | |
} | |
await send() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment