Last active
November 3, 2020 23:58
-
-
Save andris9/3df2d3111b1de4e5a0a51dcbb345210f to your computer and use it in GitHub Desktop.
O365 Nodemailer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint no-console: 0 */ | |
| 'use strict'; | |
| const nodemailer = require('nodemailer'); | |
| // Create a SMTP transporter object | |
| let transporter = nodemailer.createTransport({ | |
| host: 'smtp.office365.com', | |
| port: 587, | |
| auth: { | |
| user: 'areinman@org.domain', | |
| pass: 'password', | |
| }, | |
| logger: true, | |
| debug: true, // include SMTP traffic in the logs | |
| }); | |
| // Message object | |
| let message = { | |
| from: 'Andris Reinman <areinman@org.domain>', | |
| to: 'Andris Reinman <andris@ethereal.email>', | |
| subject: 'O365 test message', | |
| text: 'O365 test message', | |
| }; | |
| transporter.sendMail(message, (error, info) => { | |
| if (error) { | |
| console.log('Error occurred'); | |
| console.log(error.message); | |
| return process.exit(1); | |
| } | |
| console.log('Message sent successfully!'); | |
| console.log(info); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [2020-05-28 07:14:24] DEBUG Creating transport: nodemailer (6.4.6; +https://nodemailer.com/; SMTP/6.4.6[client:6.4.6]) | |
| [2020-05-28 07:14:24] DEBUG Sending mail using SMTP/6.4.6[client:6.4.6] | |
| [2020-05-28 07:14:24] DEBUG [P7xvpVEEM] Resolved smtp.office365.com as 40.101.126.194 [cache miss] | |
| [2020-05-28 07:14:24] INFO [P7xvpVEEM] Connection established to 40.101.126.194:587 | |
| [2020-05-28 07:14:24] DEBUG [P7xvpVEEM] S: 220 HE1P190CA0042.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 28 May 2020 07:14:24 +0000 | |
| [2020-05-28 07:14:24] DEBUG [P7xvpVEEM] C: EHLO [127.0.0.1] | |
| [2020-05-28 07:14:24] DEBUG [P7xvpVEEM] S: 250-HE1P190CA0042.outlook.office365.com Hello [90.191.155.125] | |
| [2020-05-28 07:14:24] DEBUG [P7xvpVEEM] S: 250-SIZE 157286400 | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-PIPELINING | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-DSN | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-ENHANCEDSTATUSCODES | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-STARTTLS | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-8BITMIME | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-BINARYMIME | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-CHUNKING | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250 SMTPUTF8 | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] C: STARTTLS | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 220 2.0.0 SMTP server ready | |
| [2020-05-28 07:14:25] INFO [P7xvpVEEM] Connection upgraded with STARTTLS | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] C: EHLO [127.0.0.1] | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-HE1P190CA0042.outlook.office365.com Hello [90.191.155.125] | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-SIZE 157286400 | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-PIPELINING | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-DSN | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-ENHANCEDSTATUSCODES | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-AUTH LOGIN XOAUTH2 | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-8BITMIME | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-BINARYMIME | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250-CHUNKING | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250 SMTPUTF8 | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] SMTP handshake finished | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] C: AUTH LOGIN | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 334 VXNlcm5hbWU6 | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] C: <base64:areinman@org.domain> | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 334 UGFzc3dvcmQ6 | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] C: <base64:password> | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 235 2.7.0 Authentication successful | |
| [2020-05-28 07:14:25] INFO [P7xvpVEEM] User "areinman@org.domain" authenticated | |
| [2020-05-28 07:14:25] INFO Sending message <ad790f70-e29e-60ce-36e8-8bb99f17d19c@org.domain> to <andris@ethereal.email> | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] C: MAIL FROM:<areinman@org.domain> | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250 2.1.0 Sender OK | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] C: RCPT TO:<andris@ethereal.email> | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 250 2.1.5 Recipient OK | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] C: DATA | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] S: 354 Start mail input; end with <CRLF>.<CRLF> | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] Content-Type: text/plain | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] From: Andris Reinman <areinman@org.domain> | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] To: Andris Reinman <andris@ethereal.email> | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] Subject: O365 test message | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] Message-ID: <ad790f70-e29e-60ce-36e8-8bb99f17d19c@org.domain> | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] Content-Transfer-Encoding: 7bit | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] Date: Thu, 28 May 2020 07:14:24 +0000 | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] MIME-Version: 1.0 | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] O365 test message | |
| [2020-05-28 07:14:25] DEBUG [P7xvpVEEM] . | |
| [2020-05-28 07:14:25] INFO [P7xvpVEEM] <324 bytes encoded mime message (source size 321 bytes)> | |
| [2020-05-28 07:14:26] DEBUG [P7xvpVEEM] S: 250 2.0.0 OK <ad790f70-e29e-60ce-36e8-8bb99f17d19c@org.domain> [Hostname=HE1PR03MB3116.eurprd03.prod.outlook.com] | |
| [2020-05-28 07:14:26] DEBUG [P7xvpVEEM] Closing connection to the server using "end" | |
| Message sent successfully! | |
| { | |
| accepted: [ 'andris@ethereal.email' ], | |
| rejected: [], | |
| envelopeTime: 52, | |
| messageTime: 451, | |
| messageSize: 324, | |
| response: '250 2.0.0 OK <ad790f70-e29e-60ce-36e8-8bb99f17d19c@org.domain> [Hostname=HE1PR03MB3116.eurprd03.prod.outlook.com]', | |
| envelope: { from: 'areinman@org.domain', to: [ 'andris@ethereal.email' ] }, | |
| messageId: '<ad790f70-e29e-60ce-36e8-8bb99f17d19c@org.domain>' | |
| } | |
| [2020-05-28 07:14:26] INFO [P7xvpVEEM] Connection closed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment