This was a bug in the nodemailer library which has now been promptly fixed by the author after explaining what was causing the problem.
Further details available here: https://github.com/andris9/Nodemailer/issues/141. On Wednesday, 27 February 2013 14:57:26 UTC, Rikki Loades wrote: > > So I have this rather random error in NodeJS which is providing me no > information as to what is causing the error: > > <code> > stream.js:81 > throw er; // Unhandled stream error in pipe. > ^ > Error: write EPIPE > at errnoException (net.js:770:11) > at Object.afterWrite (net.js:594:19) > </code> > > And this is the code that is causing the error: > <code> > > var nodemailer = require('nodemailer'); > var NewsletterEmail = require('./NewsletterEmail.js'); > > function NewsletterMailer(fromEmail) > { > this._from = fromEmail; > this._transport = nodemailer.createTransport('Sendmail'); > } > > NewsletterMailer.prototype = { > send: function(email, newsletterEmail, callback) { > var mailOptions = { > to: email, > from: this._from, > subject: newsletterEmail.getSubject(), > html: newsletterEmail.buildHTML(email), > text: newsletterEmail.buildText(email) > }; > > this._transport.sendMail(mailOptions, callback); > }, > > close: function() { > this._transport.close(); > } > } > > function Newsletter() > { > this._id = 1; > this.countSent = 0; > this.emailsToSend = ['[email protected]', '[email protected]', ' > [email protected]', '[email protected]', '[email protected]', ' > [email protected]']; > } > > Newsletter.prototype.send = function() { > var newsletter = this; > > var newsletterEmail = NewsletterEmail.create('folder', 'file'); > var mailer = new NewsletterMailer('[email protected]'); > > function sendEmail() { > var email = newsletter.emailsToSend.pop(); > > mailer.send(email, newsletterEmail, function(mailerErr) { > if (mailerErr) { > console.log('Mailer error: ', mailerErr); > } > > newsletter.countSent++; > > console.log('progress ' + newsletter.countSent); > > if (newsletter.emailsToSend.length > 0) { > sendEmail(); > } > else { > mailer.close(); > console.log('complete'); > } > }); > } > > sendEmail(); > } > > var nl = new Newsletter(); > nl.send(); > </code> > > When calling sendNew I will randomly get the EPIPE error at certain. > > Anybody got any ideas or tips for debugging this problem? Anything would > be very much appreciated at this point. > > The stack trace is fairly useless here and all the other solutions ive > seen have be todo with process spawning or the connect web framework. > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
