Skip to content

Instantly share code, notes, and snippets.

@Maxim-Kolmogorov
Created January 24, 2024 07:54
Show Gist options
  • Save Maxim-Kolmogorov/ff92be8065318092d561eb0f58b79780 to your computer and use it in GitHub Desktop.
Save Maxim-Kolmogorov/ff92be8065318092d561eb0f58b79780 to your computer and use it in GitHub Desktop.
Send Email with Nodemailer.
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