0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Merge pull request #5243 from jaswilli/mail-errors

Check error object before dereference
This commit is contained in:
Hannah Wolfe 2015-05-11 09:55:25 +01:00
commit 79ff297490

View file

@ -92,7 +92,8 @@ GhostMailer.prototype.send = function (message) {
response.statusHandler.once('failed', function (data) {
var reason = 'Email Error: Failed sending email';
if (data.error.errno === 'ENOTFOUND') {
if (data.error && data.error.errno === 'ENOTFOUND') {
reason += ': there is no mail server at this address: ' + data.domain;
}
reason += '.';
@ -100,7 +101,13 @@ GhostMailer.prototype.send = function (message) {
});
response.statusHandler.once('requeue', function (data) {
return reject(new Error('Email Error: message was not sent, requeued. Probably will not be sent. :( \nMore info: ' + data.error.message));
var errorMessage = 'Email Error: message was not sent, requeued. Probably will not be sent. :(';
if (data.error && data.error.message) {
errorMessage += '\nMore info: ' + data.error.message;
}
return reject(new Error(errorMessage));
});
response.statusHandler.once('sent', function () {