mirror of
https://github.com/eleith/emailjs.git
synced 2024-07-05 20:10:37 +00:00
support return-path properly and ensure quit finishes before calling callback
This commit is contained in:
parent
4ca1742751
commit
19f3686f1d
@ -108,6 +108,9 @@ Client.prototype =
|
||||
if(msg.header.bcc)
|
||||
stack.to = stack.to.concat(address.parse(msg.header.bcc));
|
||||
|
||||
if(msg.header['return-path'] && address.parse(msg.header['return-path']).length)
|
||||
stack.returnPath = address.parse(msg.header['return-path'])[0].address;
|
||||
|
||||
self.queue.push(stack);
|
||||
self._poll();
|
||||
}
|
||||
@ -160,8 +163,9 @@ Client.prototype =
|
||||
_sendmail: function(stack)
|
||||
{
|
||||
var self = this;
|
||||
var from = stack.returnPath || stack.from;
|
||||
self.sending = true;
|
||||
self.smtp.mail(self._sendsmtp(stack, self._sendrcpt), '<' + stack.from + '>');
|
||||
self.smtp.mail(self._sendsmtp(stack, self._sendrcpt), '<' + from + '>');
|
||||
},
|
||||
|
||||
_sendrcpt: function(stack)
|
||||
|
12
smtp/smtp.js
12
smtp/smtp.js
@ -105,7 +105,12 @@ SMTP.prototype = {
|
||||
self.port = port || self.port;
|
||||
self.ssl = options.ssl || self.ssl;
|
||||
|
||||
if (self._state != SMTPState.NOTCONNECTED) self.quit();
|
||||
if (self._state != SMTPState.NOTCONNECTED) {
|
||||
self.quit(function() {
|
||||
self.connect(callback, port, host, options);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var connected = function(err) {
|
||||
if (!err) {
|
||||
@ -136,8 +141,9 @@ SMTP.prototype = {
|
||||
caller(callback, null, msg.data);
|
||||
} else {
|
||||
log("response (data): " + msg.data);
|
||||
self.quit();
|
||||
caller(callback, SMTPError("bad response on connection", SMTPError.BADRESPONSE, err, msg.data));
|
||||
self.quit(function() {
|
||||
caller(callback, SMTPError("bad response on connection", SMTPError.BADRESPONSE, err, msg.data));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user