sending emails with nodemailer outlook account

Solutions on MaxInterview for sending emails with nodemailer outlook account by the best coders in the world

showing results for - "sending emails with nodemailer outlook account"
Davide
07 May 2019
1var nodemailer = require('nodemailer');
2
3// Create the transporter with the required configuration for Outlook
4// change the user and pass !
5var transporter = nodemailer.createTransport({
6    host: "smtp-mail.outlook.com", // hostname
7    secureConnection: false, // TLS requires secureConnection to be false
8    port: 587, // port for secure SMTP
9    tls: {
10       ciphers:'SSLv3'
11    },
12    auth: {
13        user: 'mymail@outlook.com',
14        pass: 'myPassword'
15    }
16});
17
18// setup e-mail data, even with unicode symbols
19var mailOptions = {
20    from: '"Our Code World " <mymail@outlook.com>', // sender address (who sends)
21    to: 'mymail@mail.com, mymail2@mail.com', // list of receivers (who receives)
22    subject: 'Hello ', // Subject line
23    text: 'Hello world ', // plaintext body
24    html: '<b>Hello world </b><br> This is the first email sent with Nodemailer in Node.js' // html body
25};
26
27// send mail with defined transport object
28transporter.sendMail(mailOptions, function(error, info){
29    if(error){
30        return console.log(error);
31    }
32
33    console.log('Message sent: ' + info.response);
34});
35