Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to include attachments #69

Open
jdarling opened this issue Apr 13, 2012 · 3 comments
Open

Ability to include attachments #69

jdarling opened this issue Apr 13, 2012 · 3 comments

Comments

@jdarling
Copy link

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

@jdarling
Copy link
Author

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...

@andris9
Copy link

andris9 commented Apr 13, 2012

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)

@echessa
Copy link

echessa commented Apr 16, 2012

I tried to use attachments as demonstrated in the https://github.com/andris9/Nodemailer 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants