SMTPClient: Relaying: add safeguard we don't try to attempt to deliver directly.
[citadel.git] / citadel / modules / smtp / serv_smtpeventclient.c
index c7de74fac3e9da7fffd65b10251b42c36a9411af..9e97dda97aed2e8660abb7b31cf1d46b3d0e83f1 100644 (file)
@@ -233,10 +233,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__);