]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/smtp/serv_smtpeventclient.c
SMTP-Client: fix trigger when to send bounce messages
[citadel.git] / citadel / modules / smtp / serv_smtpeventclient.c
index c7de74fac3e9da7fffd65b10251b42c36a9411af..d8f46ca93c10fddc02ff4a072b98dfc93d748c14 100644 (file)
@@ -153,9 +153,10 @@ eNextState FinalizeMessageSend_DB(AsyncIO *IO)
 
        Msg->IDestructQueItem = DecreaseQReference(Msg->MyQItem);
 
-       Msg->nRemain = CountActiveQueueEntries(Msg->MyQItem);
+       Msg->nRemain = CountActiveQueueEntries(Msg->MyQItem, 0);
 
        if (Msg->MyQEntry->Active && 
+           !Msg->MyQEntry->StillActive &&
            CheckQEntryIsBounce(Msg->MyQEntry))
        {
                /* are we casue for a bounce mail? */
@@ -233,10 +234,17 @@ eNextState FailOneAttempt(AsyncIO *IO)
         * - connection timeout
         * - dns lookup failed
         */
-       StopClientWatchers(IO);
+       StopClientWatchers(IO, 1);
 
        if (Msg->pCurrRelay != NULL)
                Msg->pCurrRelay = Msg->pCurrRelay->Next;
+       if ((Msg->pCurrRelay != NULL) &&
+           !Msg->pCurrRelay->IsRelay &&
+           Msg->MyQItem->HaveRelay)
+       {
+               EVS_syslog(LOG_DEBUG, "%s Aborting; last relay failed.\n", __FUNCTION__);
+               return eAbort;
+       }
 
        if (Msg->pCurrRelay == NULL) {
                EVS_syslog(LOG_DEBUG, "%s Aborting\n", __FUNCTION__);