Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const nodemailer = require('nodemailer');
- const transporter = nodemailer.createTransport({
- host: 'smtp.office365.com',
- port: 587,
- secure: false, // secure:true for port 465, secure:false for port 587
- auth: {
- user: 'gil.felot@myaccount.com',
- pass: 'MyPassWord'
- }
- });
- // Check the connection to the service.
- transporter.verify(function(error, success) {
- if (error) {
- console.log(error);
- } else {
- console.log('Server is ready to take our messages');
- }
- });
- const email = {
- from: 'gil.felot@myaccount.com', // sender address
- to: 'mygmailaccount@gmail.com', // list of receivers
- subject: 'Test Nodemailer', // Subject line
- // text: req.body.text, // plaintext body
- html: '<b>Hello world 🐴</b>', // html body
- attachments: [
- {
- filename: file.originalname,
- contents: new Buffer(file.buffer, 'base64'),
- encoding: 'base64'
- }
- ]
- };
- return hook.app.service('mail').create(email)
- .then(function (result) {
- console.log('Sent email', result);
- }).catch(err => {
- console.log(err);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement