Skip to content

Instantly share code, notes, and snippets.

@Maxim-Kolmogorov
Created January 24, 2024 07:54
Show Gist options
  • Select an option

  • Save Maxim-Kolmogorov/ff92be8065318092d561eb0f58b79780 to your computer and use it in GitHub Desktop.

Select an option

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: 'login@gmail.com',
pass: 'pass'
}
})
const mailOptions = {
from: 'login@gmail.com',
to: 'to.my@gmail.com',
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