Skip to content

Instantly share code, notes, and snippets.

@jgatjens
Created July 31, 2021 01:59
Show Gist options
  • Save jgatjens/2b2bdaab1ad7f982745789802a108369 to your computer and use it in GitHub Desktop.
Save jgatjens/2b2bdaab1ad7f982745789802a108369 to your computer and use it in GitHub Desktop.
node.js send email with gmail account
var nodemailer = require('nodemailer');
var fromEmail = '[email protected]';
var fromPassword = '****';
var toEmail = ['[email protected]'];
// Defined transport
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: fromEmail,
pass: fromPassword
}
});
const text = `
Make sure that you are informed on the travel restrictions and entry
requirements of the country you are traveling to, in order to ensure
that you arrive to your destination without any mishap. Remember,
the test must be taken no more than 72 hours berfore leaving the country.
If you are in San José:
Get tested in the comfort of your hotel or visit any of our 23 laboratories located in San José.
Rapid RT- PRC TEST
* Escazú, 25m Norte del Restaurante Mc Donalds de Escazú.
* Liberia, Solarium Logistic Center & Aeropuerto Internacional Daniel Oduber`
const html = `
<p>Make sure that you are informed on the travel restrictions and entry
requirements of the country you are traveling to, in order to ensure
that you arrive to your destination without any mishap. Remember,
the test must be taken no more than 72 hours berfore leaving the country.</p>
<h3>If you are in San José:</h3>
<p>Get tested in the comfort of your hotel or visit any of our 23 laboratories located in San José.</p>
<h3>Rapid RT- PRC TEST</h3>
<p>Escazú, 25m Norte del Restaurante Mc Donalds de Escazú.</p>
<p>Liberia, Solarium Logistic Center & Aeropuerto Internacional Daniel Oduber</p>`
transporter.sendMail({
from: '"Fabiola Monge" <[email protected]>',
to: toEmail,
subject: 'http://labechandi.com/ Analysis - Giulia Minati',
attachments: [
{
filename: '8b0aa081-d917-1a58-2447-856dc1fb0bf5.pdf',
path: '/Users/jairo.gatjens/send_email/8b0aa081-d917-1a58-2447-856dc1fb0bf5.pdf'
}
],
text: text,
html: html
}, function (error, response) {
if (error) {
console.log(error);
console.log('Failed in sending mail');
} else {
console.log('Successfully send email');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment