[nodejs] node-sendmail: Send mail without setting up SMTP server

2,852 views
Skip to first unread message

jason.桂林

unread,
May 5, 2011, 2:28:45 PM5/5/11
to nod...@googlegroups.com
I have just spent some time to learning SMTP, and write a simple program which allows you sendmail without setting up a SMTP server.

var sendmail = require('sendmail');
sendmail.sendmail({
  subject: 'The subject',
  type: 'text/html',
  content: '<h3>hello</h3><p>Hey guys</p>'
})

As you see, you don't need to set up SMTP server and username and password.

https://github.com/guileen/node-sendmail

This project is just for sending "noreply" mails. you probably still need to set up reverse DNS like what a mail server should do to prevent the recipient server treat you as spam.

Also I am glad to introduce a great utility lib of email, node-sendmail planning to using it.
https://github.com/andris9/mimelib

--
Best regards,

Jason Green
桂林


Matt

unread,
May 5, 2011, 2:43:45 PM5/5/11
to nod...@googlegroups.com
Nice work - good to see someone else working on SMTP too.

I will note this is missing a bunch of things that you have to do for SMTP outbound, but are implemented fully in Haraka's deliver plugin, please feel absolutely free to use any code you need from there: https://github.com/baudehlo/Haraka/blob/master/plugins/queue/deliver.js

(off the top of my head: retrying upon a lot of failure cases [*], mixing up MXs of the same priority, trying all A records for an individual MX, trying for an A record if the MX returns no data...).

Also your line based socket approach assumes a line isn't split across packet boundaries, which will break it. Won't happen very often with SMTP, but you never know.

Matt.

[*] Though this kind-of requires a disk-backed queue, so you may not wish to add that in.

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

jason.桂林

unread,
May 5, 2011, 8:24:03 PM5/5/11
to nod...@googlegroups.com

great, your code will help me, actually haraka is the first of my looking, a little complex for me, thank you for let me know these problems.

在 2011-5-6 上午2:43,"Matt" <hel...@gmail.com>编写:



Nice work - good to see someone else working on SMTP too.

I will note this is missing a bunch of things that you have to do for SMTP outbound, but are implemented fully in Haraka's deliver plugin, please feel absolutely free to use any code you need from there: https://github.com/baudehlo/Haraka/blob/master/plugins/queue/deliver.js

(off the top of my head: retrying upon a lot of failure cases [*], mixing up MXs of the same priority, trying all A records for an individual MX, trying for an A record if the MX returns no data...).

Also your line based socket approach assumes a line isn't split across packet boundaries, which will break it. Won't happen very often with SMTP, but you never know.

Matt.

[*] Though this kind-of requires a disk-backed queue, so you may not wish to add that in.

On Thu, May 5, 2011 at 2:28 PM, jason.桂林 <gui...@gmail.com> wrote:

>
> I have just spent some time to learning SMTP, and write a simple program which allows you sendma...

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

Reply all
Reply to author
Forward
0 new messages