1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-23 15:58:49 -05:00

send emails in outbox subsequently

This commit is contained in:
Felix Hammerl 2013-10-24 16:45:54 +02:00
parent 5b895cb61e
commit 2a201e52e6

View File

@ -111,16 +111,18 @@ define(function(require) {
// update outbox folder count
outbox.count = pending.length;
$scope.$apply();
if (pending.length < 1) {
return;
}
// sending the first one pending
send(pending[0]);
// sending pending mails
send(pending);
});
}
function send(email) {
function send(emails) {
if (emails.length === 0) {
return;
}
var email = emails.shift();
emailDao.smtpSend(email, function(err) {
if (err) {
console.error(err);
@ -128,6 +130,7 @@ define(function(require) {
}
removeFromStorage(email.id);
send(emails);
});
}