1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-24 16:28: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 // update outbox folder count
outbox.count = pending.length; outbox.count = pending.length;
$scope.$apply(); $scope.$apply();
if (pending.length < 1) {
return;
}
// sending the first one pending // sending pending mails
send(pending[0]); send(pending);
}); });
} }
function send(email) { function send(emails) {
if (emails.length === 0) {
return;
}
var email = emails.shift();
emailDao.smtpSend(email, function(err) { emailDao.smtpSend(email, function(err) {
if (err) { if (err) {
console.error(err); console.error(err);
@ -128,6 +130,7 @@ define(function(require) {
} }
removeFromStorage(email.id); removeFromStorage(email.id);
send(emails);
}); });
} }