Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Ability to include attachments #69

jdarling opened this Issue · 3 comments

3 participants


It would be great if you could attach files to the emails that are being sent. Looking at sample PHP code from ( ) this might not be difficult to achieve. Will look into it more and post back what I find.


Here is a start (the code to encode source stream or file into base64 chunk data):

var encodeStreamForEmail = function(source, callback){
var content64 = source.toString('base64');
var chunklen = 76;
var endWith = '\r\n';
var contentEncoded = [];
var i = 0, l = content64.length;
for(; i < l; i+=chunklen){
contentEncoded.push(content64.substr(i, chunklen));
callback(null, contentEncoded.join(endWith));

var encodeFileForEmail = function(sourceFileName, callback){
var fs = require('FS');
fs.readFile(sourceFileName, function(data){
encodeStreamForEmail(data, callback);

Still have to look into header's, mime types, etc...


I'm not sure if and how node_mailer handles attachments but Nodemailer which is beneath node_mailer used for the transport supports any kind of attachments (files, streams, strings)


I tried to use attachments as demonstrated in the example using this node_mailer(Marak's) but I got this error: Cannot call method 'replace' of undefined. Does anyone know how to include attachments using node_mailer. I chose node_mailer over Nodemailer because it supports use of templates so I'd prefer to send attachments with node_mailer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.