Skip to content

Commit 4897202

Browse files
committed
Fix MailMessage.callback().
1 parent cada7a2 commit 4897202

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- updated: `U.getExtension()` returns lower-case extensions
1313

1414
- fixed: (IMPORTANT) long messages in WebSocket
15+
- fixed: moved executing of `MailMessage.callback()` to better place
1516
- fixed: mail auth when `options.user` and `options.password` are blank
1617

1718
======= 2.7.0

mail.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,16 +345,19 @@ Mailer.prototype.destroy = function(obj) {
345345
return this;
346346
};
347347

348+
const ATTACHMENT_SO = { encoding: 'base64' };
348349
Mailer.prototype.$writeattachment = function(obj) {
349350

350351
var attachment = obj.files ? obj.files.shift() : false;
351352
if (!attachment) {
352353
mailer.$writeline(obj, '--' + obj.boundary + '--', '', '.');
354+
obj.messagecallback && obj.messagecallback(null, obj.instance);
355+
obj.messagecallback = null;
353356
return this;
354357
}
355358

356359
var name = attachment.name;
357-
var stream = Fs.createReadStream(attachment.filename, { encoding: 'base64' });
360+
var stream = Fs.createReadStream(attachment.filename, ATTACHMENT_SO);
358361
var message = [];
359362
var extension = attachment.extension;
360363
var isCalendar = extension === 'ics';
@@ -721,8 +724,6 @@ Mailer.prototype.$send = function(obj, options, autosend) {
721724
case 235: // VERIFY
722725
case 999: // Total.js again
723726

724-
obj.messagecallback && obj.messagecallback(null, obj.instance);
725-
obj.messagecallback = null;
726727
mailer.$writeline(obj, buffer.shift());
727728

728729
if (buffer.length)

0 commit comments

Comments
 (0)