Skip to content

Instantly share code, notes, and snippets.

@andris9
Last active August 10, 2022 20:38
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andris9/93b59500e8b61a59ca21 to your computer and use it in GitHub Desktop.
Save andris9/93b59500e8b61a59ca21 to your computer and use it in GitHub Desktop.
Nodemailer using Mandrill
'use strict';
// Nodemailer: v2.0.0
// Ubuntu: 14.04
// node: v5.5.0
// npm: 3.3.12
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'Mandrill',
auth: {
user: 'andris.reinman@gmail.com',
pass: 'VALID_API_KEY'
},
logger: true, // log to console
debug: true // include SMTP traffic in the logs
}, {
from: 'Andris Reinman <andris@kreata.ee>'
});
// Message object
var message = {
to: '"Andris Reinman" <andris.reinman@gmail.com>',
subject: 'Nodemailer is unicode friendly ✔', //
text: 'Hello to myself!'
};
transporter.sendMail(message).then(info => {
console.log('Server responded with "%s"', info.response);
}).catch(err => {
console.log('Error occurred');
console.log(err.message);
});
2016-01-31 17:04:18] INFO: Sending mail using SMTP/2.0.0[client:2.0.0]
[2016-01-31 17:04:18] INFO: [1gJLxuUSxz0] Connection established to 54.72.103.126:587
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] S: 220 smtp.mandrillapp.com ESMTP
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] C: EHLO [127.0.0.1]
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] S: 250-relay-5.eu-west-1.relay-prod
250-PIPELINING
250-SIZE 26214400
250-STARTTLS
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250 8BITMIME
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] C: STARTTLS
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] S: 220 2.0.0 Ready to start TLS
[2016-01-31 17:04:18] INFO: [1gJLxuUSxz0] Connection upgraded with STARTTLS
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] C: EHLO [127.0.0.1]
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] S: 250-relay-5.eu-west-1.relay-prod
250-PIPELINING
250-SIZE 26214400
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250 8BITMIME
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] SMTP handshake finished
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] C: AUTH PLAIN {*AUTH DATA*}
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] S: 235 2.7.0 Authentication successful
[2016-01-31 17:04:18] INFO: [1gJLxuUSxz0] User "andris.reinman@gmail.com" authenticated
[2016-01-31 17:04:18] INFO: Sending message <> to <andris.reinman@gmail.com>
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] C: MAIL FROM:<andris@kreata.ee>
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] S: 250 2.1.0 Ok
[2016-01-31 17:04:18] DEBUG: [1gJLxuUSxz0] C: RCPT TO:<andris.reinman@gmail.com>
[2016-01-31 17:04:19] DEBUG: [1gJLxuUSxz0] S: 250 2.1.5 Ok
[2016-01-31 17:04:19] DEBUG: [1gJLxuUSxz0] C: DATA
[2016-01-31 17:04:19] DEBUG: [1gJLxuUSxz0] S: 354 End data with <CR><LF>.<CR><LF>
[2016-01-31 17:04:19] DEBUG: [1gJLxuUSxz0] C: Content-Type: text/plain
From: Andris Reinman <andris@kreata.ee>
To: Andris Reinman <andris.reinman@gmail.com>
Subject: Nodemailer is unicode friendly =?UTF-8?Q?=E2=9C=94?=
X-Mailer: nodemailer (2.0.0; +http://nodemailer.com/;
SMTP/2.0.0[client:2.0.0])
Content-Transfer-Encoding: 7bit
Date: Sun, 31 Jan 2016 17:04:18 +0000
Message-Id: <1454259858867-2b5996b0-1e26e119-6441b841@kreata.ee>
MIME-Version: 1.0
[2016-01-31 17:04:19] DEBUG: [1gJLxuUSxz0] C: Hello to myself!
[2016-01-31 17:04:19] DEBUG: [1gJLxuUSxz0] C:
.
[2016-01-31 17:04:19] INFO: [1gJLxuUSxz0] C: <440 bytes encoded mime message (source size 435 bytes)>
[2016-01-31 17:04:19] DEBUG: [1gJLxuUSxz0] S: 250 2.0.0 Ok: queued as E7224480BF7
[2016-01-31 17:04:19] DEBUG: [1gJLxuUSxz0] Closing connection to the server using "end"
Server responded with "250 2.0.0 Ok: queued as E7224480BF7"
[2016-01-31 17:04:19] INFO: [1gJLxuUSxz0] Connection closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment