-
-
Save sabasm/00e4ea2ae8866db6d1bc9e92a3da38a4 to your computer and use it in GitHub Desktop.
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
const nodemailer = require('nodemailer'); | |
const key = require('./key.json'); | |
// Change this to one of your email addresses in the organisation | |
const YOUR_EMAIL_ADDRESS = 'info@your_company.com'; | |
// Change this to the receiver to the mail | |
const SEND_TO = 'receiver@other_company.com' | |
async function start() { | |
const transporter = nodemailer.createTransport({ | |
host: 'smtp.gmail.com', | |
port: 465, | |
secure: true, | |
auth: { | |
type: 'OAuth2', | |
user: YOUR_EMAIL_ADDRESS, | |
serviceClient: key.client_id, | |
privateKey: key.private_key, | |
}, | |
}); | |
try { | |
await transporter.verify(); | |
await transporter.sendMail({ | |
from: YOUR_EMAIL_ADDRESS, | |
to: SEND_TO, | |
subject: 'John Doe opens new farm YOU GOTTA SEE IT', | |
text: 'It is beautiful.', | |
}); | |
} catch (err) { | |
console.error(err); | |
} | |
} | |
start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment