Skip to content

Instantly share code, notes, and snippets.

@Roverr
Created February 26, 2019 00:14
Show Gist options
  • Save Roverr/9f6564f90dd99424a6bbd3438e5ec3b1 to your computer and use it in GitHub Desktop.
Save Roverr/9f6564f90dd99424a6bbd3438e5ec3b1 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();
@pvanagtmaal
Copy link

Thank you very much for guiding me through the Google maze :) All working perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment