Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Pass the correct callback to dispatchMail #65

Open
wants to merge 1 commit into from

1 participant

@smurthas

If several messages got queued up during the fs.readFile call for a single template, when the template was finally loaded, dispatchMail would get called for each message, but would get passed the callback associated with the first one (the only one that invoked the fs.readFile call). This bundles the callback in with the message itself, ensuring that the callback associated with that message is the one passed to dispatchMail

@smurthas smurthas bundle the callback associated with this specific message in with the…
… message itself, and call that once it can been sent.
c7a03f0
@smurthas

Do you think you'll be able to pull this in anytime soon? We've been pointing to my fork in our package.json for a while now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 14, 2012
  1. @smurthas

    bundle the callback associated with this specific message in with the…

    smurthas authored
    … message itself, and call that once it can been sent.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  lib/node_mailer.js
View
3  lib/node_mailer.js
@@ -86,6 +86,7 @@ function merge(x,y) {
var pool = new SMTPClientPool();
exports.send = function node_mail(message, callback) {
+ message._callback = callback;
var server = {
host: message.host,
hostname: message.domain,
@@ -147,7 +148,7 @@ exports.send = function node_mail(message, callback) {
_templateCache[message.template].queue.push(message);
_templateCache[message.template].queue.forEach(function(msg, i){
msg.html = mustache.to_html(_templateCache[message.template].template, msg.data);
- dispatchMail(msg, server, callback);
+ dispatchMail(msg, server, msg._callback);
});
// Clear the queue out
Something went wrong with that request. Please try again.