Skip to content

Instantly share code, notes, and snippets.

@andris9
Created April 28, 2011 15:17
Show Gist options
  • Save andris9/946544 to your computer and use it in GitHub Desktop.
Save andris9/946544 to your computer and use it in GitHub Desktop.
send 10 e-mail messages at once
var
nodemailer = require('./extlib/andris9-Nodemailer-1034ae8/lib/mail');
if(true){
/*
nodemailer.SMTP = {
host: "localhost",
port: 25,
use_authentication: false,
}*/
// Message object
var message = {
sender: '"test" <test1@example.com>',
to: '"test" <test2@example.com>',
subject: "Nodemailer is unicode friendly €þÖÄÜÕ",
body: "text content",
html:"€html content",
}
// Callback to be run after the sending is completed
var callback = function(error, success, id){
console.log('callback for message '+id+', err:'+!!error+', suc: '+success);
if(error){
console.log("Error occured, "+error.message);
return;
}
if(success){
console.log("Message sent successfully!");
}else{
console.log("Message failed, reschedule!");
}
}
for(var i =0; i< 10; i++){
(function(i){
nodemailer.send_mail(message, function(error, success){callback(error, success, i)});
})(i);
}
}
CONNECTION: 220 srv.example.com ESMTP Postfix
Connection established!
SEND:
"EHLO srv.example.com\r\n"
RECEIVE:
"250-srv.example.com\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n"
SEND:
"MAIL FROM:<test@example.com>\r\n"
CONNECTION: 220 srv.example.com ESMTP Postfix
Connection established!
SEND:
"EHLO srv.example.com\r\n"
RECEIVE:
"250-srv.example.com\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n"
SEND:
"MAIL FROM:<test@example.com>\r\n"
RECEIVE:
"250 2.1.0 Ok\r\n"
SEND:
"RCPT TO:<test1@example.com>\r\n"
RECEIVE:
"250 2.1.0 Ok\r\n"
SEND:
"RCPT TO:<test1@example.com>\r\n"
CONNECTION: 220 srv.example.com ESMTP Postfix
Connection established!
SEND:
"EHLO srv.example.com\r\n"
RECEIVE:
"250-srv.example.com\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n"
SEND:
"MAIL FROM:<test@example.com>\r\n"
RECEIVE:
"250 2.1.0 Ok\r\n"
SEND:
"RCPT TO:<test1@example.com>\r\n"
RECEIVE:
"250 2.1.5 Ok\r\n"
SEND:
"DATA\r\n"
RECEIVE:
"354 End data with <CR><LF>.<CR><LF>\r\n"
SEND:
"X-Mailer: Nodemailer (0.1.9; +http://www.nodemailer.org)\r\nFrom: \"test\" <test@example.com>\r\nTo: \"test\" <test1@example.com>\r\nSubject: =?UTF-8?Q?Nodemailer_test_=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95?=\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=----NODEMAILER-1-1301474426163\r\n\r\n"
SEND:
"------NODEMAILER-1-1301474426163\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95 Hello to myself\r\n\r\n------NODEMAILER-1-1301474426163\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95<br/><p><b>Hello</b> to myself</p>\r\n\r\n------NODEMAILER-1-1301474426163--"
SEND:
"\r\n.\r\n"
CONNECTION: 220 srv.example.com ESMTP Postfix
Connection established!
SEND:
"EHLO srv.example.com\r\n"
RECEIVE:
"250-srv.example.com\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n"
SEND:
"MAIL FROM:<test@example.com>\r\n"
RECEIVE:
"250 2.1.0 Ok\r\n"
SEND:
"RCPT TO:<test1@example.com>\r\n"
RECEIVE:
"250 2.1.5 Ok\r\n"
SEND:
"DATA\r\n"
RECEIVE:
"354 End data with <CR><LF>.<CR><LF>\r\n"
SEND:
"X-Mailer: Nodemailer (0.1.9; +http://www.nodemailer.org)\r\nFrom: \"test\" <test@example.com>\r\nTo: \"test\" <test1@example.com>\r\nSubject: =?UTF-8?Q?Nodemailer_test_=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95?=\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=----NODEMAILER-2-1301474426167\r\n\r\n"
SEND:
"------NODEMAILER-2-1301474426167\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95 Hello to myself\r\n\r\n------NODEMAILER-2-1301474426167\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95<br/><p><b>Hello</b> to myself</p>\r\n\r\n------NODEMAILER-2-1301474426167--"
SEND:
"\r\n.\r\n"
callback for message 9, err:true, suc: null
Error occured, Timeout waiting for response from server
callback for message 8, err:true, suc: null
Error occured, Timeout waiting for response from server
callback for message 7, err:true, suc: null
Error occured, Timeout waiting for response from server
callback for message 6, err:true, suc: null
Error occured, Timeout waiting for response from server
callback for message 5, err:true, suc: null
Error occured, Timeout waiting for response from server
callback for message 4, err:true, suc: null
Error occured, Timeout waiting for response from server
CONNECTION: 220 srv.example.com ESMTP Postfix
Connection established!
SEND:
"EHLO srv.example.com\r\n"
RECEIVE:
"250-srv.example.com\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n"
SEND:
"MAIL FROM:<test@example.com>\r\n"
RECEIVE:
"250 2.1.0 Ok\r\n"
SEND:
"RCPT TO:<test1@example.com>\r\n"
RECEIVE:
"250 2.1.5 Ok\r\n"
SEND:
"DATA\r\n"
RECEIVE:
"354 End data with <CR><LF>.<CR><LF>\r\n"
SEND:
"X-Mailer: Nodemailer (0.1.9; +http://www.nodemailer.org)\r\nFrom: \"test\" <test@example.com>\r\nTo: \"test\" <test1@example.com>\r\nSubject: =?UTF-8?Q?Nodemailer_test_=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95?=\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=----NODEMAILER-3-1301474426167\r\n\r\n"
SEND:
"------NODEMAILER-3-1301474426167\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95 Hello to myself\r\n\r\n------NODEMAILER-3-1301474426167\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95<br/><p><b>Hello</b> to myself</p>\r\n\r\n------NODEMAILER-3-1301474426167--"
SEND:
"\r\n.\r\n"
RECEIVE:
"250 2.0.0 Ok: queued as 3D6773025210\r\n"
SEND:
"QUIT\r\n"
CONNECTION: 220 srv.example.com ESMTP Postfix
Connection established!
SEND:
"EHLO srv.example.com\r\n"
RECEIVE:
"221 2.0.0 Bye\r\n"
callback for message 0, err:false, suc: true
Message sent successfully!
RECEIVE:
"250-srv.example.com\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n"
SEND:
"MAIL FROM:<test@example.com>\r\n"
RECEIVE:
"250 2.1.0 Ok\r\n"
SEND:
"RCPT TO:<test1@example.com>\r\n"
RECEIVE:
"250 2.1.5 Ok\r\n"
SEND:
"DATA\r\n"
RECEIVE:
"354 End data with <CR><LF>.<CR><LF>\r\n"
SEND:
"X-Mailer: Nodemailer (0.1.9; +http://www.nodemailer.org)\r\nFrom: \"test\" <test@example.com>\r\nTo: \"test\" <test1@example.com>\r\nSubject: =?UTF-8?Q?Nodemailer_test_=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95?=\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=----NODEMAILER-4-1301474426167\r\n\r\n"
SEND:
"------NODEMAILER-4-1301474426167\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95 Hello to myself\r\n\r\n------NODEMAILER-4-1301474426167\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95<br/><p><b>Hello</b> to myself</p>\r\n\r\n------NODEMAILER-4-1301474426167--"
SEND:
"\r\n.\r\n"
RECEIVE:
"250 2.1.5 Ok\r\n"
SEND:
"DATA\r\n"
RECEIVE:
"354 End data with <CR><LF>.<CR><LF>\r\n"
SEND:
"X-Mailer: Nodemailer (0.1.9; +http://www.nodemailer.org)\r\nFrom: \"test\" <test@example.com>\r\nTo: \"test\" <test1@example.com>\r\nSubject: =?UTF-8?Q?Nodemailer_test_=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95?=\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=----NODEMAILER-6-1301474426168\r\n\r\n"
SEND:
"------NODEMAILER-6-1301474426168\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95 Hello to myself\r\n\r\n------NODEMAILER-6-1301474426168\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95<br/><p><b>Hello</b> to myself</p>\r\n\r\n------NODEMAILER-6-1301474426168--"
SEND:
"\r\n.\r\n"
RECEIVE:
"250 2.0.0 Ok: queued as 43A433025211\r\n"
SEND:
"QUIT\r\n"
CONNECTION: 220 srv.example.com ESMTP Postfix
Connection established!
SEND:
"EHLO srv.example.com\r\n"
RECEIVE:
"221 2.0.0 Bye\r\n"
callback for message 1, err:false, suc: true
Message sent successfully!
RECEIVE:
"250-srv.example.com\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n"
SEND:
"MAIL FROM:<test@example.com>\r\n"
RECEIVE:
"250 2.1.0 Ok\r\n"
SEND:
"RCPT TO:<test1@example.com>\r\n"
CONNECTION: 220 srv.example.com ESMTP Postfix
Connection established!
SEND:
"EHLO srv.example.com\r\n"
RECEIVE:
"250-srv.example.com\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n"
SEND:
"MAIL FROM:<test@example.com>\r\n"
RECEIVE:
"250 2.1.0 Ok\r\n"
SEND:
"RCPT TO:<test1@example.com>\r\n"
RECEIVE:
"250 2.1.5 Ok\r\n"
SEND:
"DATA\r\n"
RECEIVE:
"354 End data with <CR><LF>.<CR><LF>\r\n"
SEND:
"X-Mailer: Nodemailer (0.1.9; +http://www.nodemailer.org)\r\nFrom: \"test\" <test@example.com>\r\nTo: \"test\" <test1@example.com>\r\nSubject: =?UTF-8?Q?Nodemailer_test_=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95?=\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=----NODEMAILER-5-1301474426167\r\n\r\n"
SEND:
"------NODEMAILER-5-1301474426167\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95 Hello to myself\r\n\r\n------NODEMAILER-5-1301474426167\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95<br/><p><b>Hello</b> to myself</p>\r\n\r\n------NODEMAILER-5-1301474426167--"
SEND:
"\r\n.\r\n"
RECEIVE:
"250 2.0.0 Ok: queued as 4818C3025212\r\n"
SEND:
"QUIT\r\n"
CONNECTION: 220 srv.example.com ESMTP Postfix
Connection established!
SEND:
"EHLO srv.example.com\r\n"
RECEIVE:
"221 2.0.0 Bye\r\n"
callback for message 2, err:false, suc: true
Message sent successfully!
RECEIVE:
"250-srv.example.com\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n"
SEND:
"MAIL FROM:<test@example.com>\r\n"
RECEIVE:
"250 2.1.0 Ok\r\n"
SEND:
"RCPT TO:<test1@example.com>\r\n"
RECEIVE:
"250 2.1.5 Ok\r\n"
SEND:
"DATA\r\n"
RECEIVE:
"354 End data with <CR><LF>.<CR><LF>\r\n"
SEND:
"X-Mailer: Nodemailer (0.1.9; +http://www.nodemailer.org)\r\nFrom: \"test\" <test@example.com>\r\nTo: \"test\" <test1@example.com>\r\nSubject: =?UTF-8?Q?Nodemailer_test_=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95?=\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=----NODEMAILER-7-1301474426168\r\n\r\n"
SEND:
"------NODEMAILER-7-1301474426168\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95 Hello to myself\r\n\r\n------NODEMAILER-7-1301474426168\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95<br/><p><b>Hello</b> to myself</p>\r\n\r\n------NODEMAILER-7-1301474426168--"
SEND:
"\r\n.\r\n"
RECEIVE:
"250 2.0.0 Ok: queued as 49FC13025213\r\n"
SEND:
"QUIT\r\n"
CONNECTION: 220 srv.example.com ESMTP Postfix
Connection established!
SEND:
"EHLO srv.example.com\r\n"
RECEIVE:
"221 2.0.0 Bye\r\n"
callback for message 3, err:false, suc: true
Message sent successfully!
RECEIVE:
"250-srv.example.com\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n"
SEND:
"MAIL FROM:<test@example.com>\r\n"
RECEIVE:
"250 2.1.0 Ok\r\n"
SEND:
"RCPT TO:<test1@example.com>\r\n"
RECEIVE:
"250 2.1.5 Ok\r\n"
SEND:
"DATA\r\n"
RECEIVE:
"354 End data with <CR><LF>.<CR><LF>\r\n"
SEND:
"X-Mailer: Nodemailer (0.1.9; +http://www.nodemailer.org)\r\nFrom: \"test\" <test@example.com>\r\nTo: \"test\" <test1@example.com>\r\nSubject: =?UTF-8?Q?Nodemailer_test_=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95?=\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=----NODEMAILER-8-1301474426168\r\n\r\n"
SEND:
"------NODEMAILER-8-1301474426168\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95 Hello to myself\r\n\r\n------NODEMAILER-8-1301474426168\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95<br/><p><b>Hello</b> to myself</p>\r\n\r\n------NODEMAILER-8-1301474426168--"
SEND:
"\r\n.\r\n"
RECEIVE:
"250 2.0.0 Ok: queued as 4E5433025214\r\n"
SEND:
"QUIT\r\n"
RECEIVE:
"221 2.0.0 Bye\r\n"
callback for message 5, err:false, suc: true
Message sent successfully!
RECEIVE:
"250 2.1.5 Ok\r\n"
SEND:
"DATA\r\n"
RECEIVE:
"354 End data with <CR><LF>.<CR><LF>\r\n"
SEND:
"X-Mailer: Nodemailer (0.1.9; +http://www.nodemailer.org)\r\nFrom: \"test\" <test@example.com>\r\nTo: \"test\" <test1@example.com>\r\nSubject: =?UTF-8?Q?Nodemailer_test_=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95?=\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=----NODEMAILER-9-1301474426168\r\n\r\n"
SEND:
"------NODEMAILER-9-1301474426168\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95 Hello to myself\r\n\r\n------NODEMAILER-9-1301474426168\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95<br/><p><b>Hello</b> to myself</p>\r\n\r\n------NODEMAILER-9-1301474426168--"
SEND:
"\r\n.\r\n"
RECEIVE:
"250 2.0.0 Ok: queued as 52E5F3025215\r\n"
SEND:
"QUIT\r\n"
RECEIVE:
"221 2.0.0 Bye\r\n"
callback for message 4, err:false, suc: true
Message sent successfully!
RECEIVE:
"250 2.1.5 Ok\r\n"
SEND:
"DATA\r\n"
RECEIVE:
"354 End data with <CR><LF>.<CR><LF>\r\n"
SEND:
"X-Mailer: Nodemailer (0.1.9; +http://www.nodemailer.org)\r\nFrom: \"test\" <test@example.com>\r\nTo: \"test\" <test1@example.com>\r\nSubject: =?UTF-8?Q?Nodemailer_test_=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95?=\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=----NODEMAILER-10-1301474426168\r\n\r\n"
SEND:
"------NODEMAILER-10-1301474426168\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95 Hello to myself\r\n\r\n------NODEMAILER-10-1301474426168\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n=E2=82=AC=C5=BE=C3=96=C3=84=C3=9C=C3=95<br/><p><b>Hello</b> to myself</p>\r\n\r\n------NODEMAILER-10-1301474426168--"
SEND:
"\r\n.\r\n"
RECEIVE:
"250 2.0.0 Ok: queued as 548C53025216\r\n"
SEND:
"QUIT\r\n"
RECEIVE:
"221 2.0.0 Bye\r\n"
callback for message 6, err:false, suc: true
Message sent successfully!
RECEIVE:
"250 2.0.0 Ok: queued as 591063025217\r\n"
SEND:
"QUIT\r\n"
RECEIVE:
"221 2.0.0 Bye\r\n"
callback for message 7, err:false, suc: true
Message sent successfully!
RECEIVE:
"250 2.0.0 Ok: queued as 5D7223025218\r\n"
SEND:
"QUIT\r\n"
RECEIVE:
"221 2.0.0 Bye\r\n"
callback for message 8, err:false, suc: true
Message sent successfully!
RECEIVE:
"250 2.0.0 Ok: queued as 5F6123025219\r\n"
SEND:
"QUIT\r\n"
RECEIVE:
"221 2.0.0 Bye\r\n"
callback for message 9, err:false, suc: true
Message sent successfully!
@andris9
Copy link
Author

andris9 commented Apr 28, 2011

e-mail address values and the server name in the script and log file are edited

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment