X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fsmtp%2Fserv_smtpqueue.c;h=0d1073558e4d32414e1102016783643858131fbf;hb=6de3c1f36c6c8e327864c6f0e8585724709f4256;hp=00b60f8fa85281f6fca198c92cb7fcc38e3ecb2e;hpb=f6e3cd67388eae6f1c6736a56c916f1a22072237;p=citadel.git diff --git a/citadel/modules/smtp/serv_smtpqueue.c b/citadel/modules/smtp/serv_smtpqueue.c index 00b60f8fa..0d1073558 100644 --- a/citadel/modules/smtp/serv_smtpqueue.c +++ b/citadel/modules/smtp/serv_smtpqueue.c @@ -483,39 +483,46 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt) StrBuf *Msg = NULL; StrBuf *BounceMB; struct recptypes *valid; + time_t now; HashPos *It; void *vQE; long len; const char *Key; + int first_attempt = 0; int successful_bounce = 0; int num_bounces = 0; int give_up = 0; syslog(LOG_DEBUG, "smtp_do_bounce() called\n"); - if (!MyQItem->SendBounceMail) + if (MyQItem->SendBounceMail == 0) return; - if ( (ev_time() - MyQItem->Submitted) > SMTP_GIVE_UP ) { - give_up = 1;/// TODO: replace time by libevq timer get + now = ev_time(); + + if ( (now - MyQItem->Submitted) > SMTP_GIVE_UP ) { + give_up = 1; + } + + if (MyQItem->Retry == SMTP_RETRY_INTERVAL) { + first_attempt = 1; } /* * Now go through the instructions checking for stuff. */ + Msg = NewStrBufPlain(NULL, 1024); It = GetNewHashPos(MyQItem->MailQEntries, 0); while (GetNextHashPos(MyQItem->MailQEntries, It, &len, &Key, &vQE)) { MailQEntry *ThisItem = vQE; - if ((ThisItem->Status == 5) || /* failed now? */ - ((give_up == 1) && - (ThisItem->Status != 2))) + if ((ThisItem->Active && (ThisItem->Status == 5)) || /* failed now? */ + ((give_up == 1) && (ThisItem->Status != 2)) || + ((first_attempt == 1) && (ThisItem->Status != 2))) /* giving up after failed attempts... */ { - if (num_bounces == 0) - Msg = NewStrBufPlain(NULL, 1024); ++num_bounces; StrBufAppendBuf(Msg, ThisItem->Recipient, 0);