* modified sendMail function to queue mails instead of immediately sending them
* fixed a small bug that caused an error message due to an undefined mail queue array
This commit is contained in:
parent
a76698be3e
commit
86061433f4
1 changed files with 9 additions and 5 deletions
|
@ -567,9 +567,7 @@ function sendMail(from, to, subject, body) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// finally send the mail
|
// finally send the mail
|
||||||
mail.send();
|
mail.queue();
|
||||||
if (mail.status != 0)
|
|
||||||
throw new MailException("mailSend");
|
|
||||||
return new Message("mailSend");
|
return new Message("mailSend");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,9 +590,15 @@ Mail.prototype.queue = function() {
|
||||||
* application-wide mail queue
|
* application-wide mail queue
|
||||||
*/
|
*/
|
||||||
function flushMailQueue() {
|
function flushMailQueue() {
|
||||||
|
if (!app.data.mailqueue)
|
||||||
|
return;
|
||||||
while (app.data.mailqueue.length) {
|
while (app.data.mailqueue.length) {
|
||||||
var result = app.data.mailqueue.pop().send();
|
var mail = app.data.mailqueue.pop();
|
||||||
app.debug("Mail transfer status: " + result);
|
mail.send();
|
||||||
|
if (mail.status > 0) {
|
||||||
|
app.debug("Mail transfer status: " + mail.status);
|
||||||
|
//throw new MailException("mailSend");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue