Skip to content

Commit fd98983

Browse files
committed
Fix mail timeout.
1 parent 957508c commit fd98983

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

mail.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,14 @@ Mailer.prototype.send = function(smtp, options, messages, callback) {
512512
mailer.$events.error && !obj.try && mailer.emit('error', err, obj);
513513
});
514514

515+
obj.socket.setTimeout(options.timeout || 8000, function() {
516+
var err = new Error(framework_utils.httpStatus(408));
517+
mailer.destroy(obj);
518+
obj.callback && obj.callback(err);
519+
obj.callback = null;
520+
mailer.$events.error && !obj.try && mailer.emit('error', err, obj);
521+
});
522+
515523
obj.socket.on('connect', () => !options.secure && mailer.$send(obj, options));
516524
return self;
517525
};
@@ -648,14 +656,6 @@ Mailer.prototype.$send = function(obj, options, autosend) {
648656

649657
isAttach && mailer.$events.send && mailer.emit('send', obj);
650658
socket.setEncoding('utf8');
651-
socket.setTimeout(options.timeout || 8000, function() {
652-
var err = new Error(framework_utils.httpStatus(408));
653-
mailer.destroy(obj);
654-
obj.callback && obj.callback(err);
655-
obj.callback = null;
656-
line = null;
657-
mailer.$events.error && !obj.try && mailer.emit('error', err, obj);
658-
});
659659

660660
socket.on('end', function() {
661661
mailer.destroy(obj);

0 commit comments

Comments
 (0)