Skip to content

Instantly share code, notes, and snippets.

@sabasm
Forked from Roverr/index.js
Created May 17, 2019 23:18
Show Gist options
  • Save sabasm/00e4ea2ae8866db6d1bc9e92a3da38a4 to your computer and use it in GitHub Desktop.
Save sabasm/00e4ea2ae8866db6d1bc9e92a3da38a4 to your computer and use it in GitHub Desktop.
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