]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/smtp/serv_smtpeventclient.c
SMPQ: we collect stati of all failed attempts; put them into the bounce messages.
[citadel.git] / citadel / modules / smtp / serv_smtpeventclient.c
index 34363eb6f64545a95ae8e88da333a3820a868180..b3ec5da0e5ff8bed1a35197d855e7fdc44b8a1ad 100644 (file)
@@ -154,7 +154,14 @@ eNextState FinalizeMessageSend_DB(AsyncIO *IO)
 {
        const char *Status;
        SmtpOutMsg *Msg = IO->Data;
-       
+       StrBuf *StatusMessage;
+
+       if (Msg->MyQEntry->AllStatusMessages != NULL)
+               StatusMessage = Msg->MyQEntry->AllStatusMessages;
+       else
+               StatusMessage = Msg->MyQEntry->StatusMessage;
+
+
        if (Msg->MyQEntry->Status == 2) {
                SetSMTPState(IO, eSTMPfinished);
                Status = "Delivery successful.";
@@ -175,7 +182,7 @@ eNextState FinalizeMessageSend_DB(AsyncIO *IO)
                   Msg->user,
                   Msg->node,
                   Msg->name,
-                  ChrPtr(Msg->MyQEntry->StatusMessage));
+                  ChrPtr(StatusMessage));
 
 
        Msg->IDestructQueItem = DecreaseQReference(Msg->MyQItem);
@@ -204,7 +211,7 @@ eNextState FinalizeMessageSend_DB(AsyncIO *IO)
        Msg->MyQItem->QueMsgID = -1;
 
        if (Msg->IDestructQueItem)
-               smtpq_do_bounce(Msg->MyQItem, Msg->msgtext, Msg->pCurrRelay);
+               smtpq_do_bounce(Msg->MyQItem, StatusMessage, Msg->msgtext, Msg->pCurrRelay);
 
        if (Msg->nRemain > 0)
        {
@@ -264,6 +271,14 @@ eNextState FailOneAttempt(AsyncIO *IO)
         */
        StopClientWatchers(IO, 1);
 
+       Msg->MyQEntry->nAttempt ++;
+       if (Msg->MyQEntry->AllStatusMessages == NULL)
+               Msg->MyQEntry->AllStatusMessages = NewStrBuf();
+
+       StrBufAppendPrintf(Msg->MyQEntry->AllStatusMessages, "%ld) ", Msg->MyQEntry->nAttempt);
+       StrBufAppendBuf(Msg->MyQEntry->AllStatusMessages, Msg->MyQEntry->StatusMessage, 0);
+       StrBufAppendBufPlain(Msg->MyQEntry->AllStatusMessages, HKEY("; "), 0);
+
        if (Msg->pCurrRelay != NULL)
                Msg->pCurrRelay = Msg->pCurrRelay->Next;
        if ((Msg->pCurrRelay != NULL) &&
@@ -766,7 +781,9 @@ eNextState SMTP_C_Timeout(AsyncIO *IO)
 
        Msg->MyQEntry->Status = 4;
        EVS_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
-       StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[Msg->State]));
+       StrBufPrintf(IO->ErrMsg, "Timeout: %s while talking to %s",
+                    ReadErrors[Msg->State].Key,
+                    Msg->mx_host);
        if (Msg->State > eRCPT)
                return eAbort;
        else
@@ -778,7 +795,10 @@ eNextState SMTP_C_ConnFail(AsyncIO *IO)
 
        Msg->MyQEntry->Status = 4;
        EVS_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
-       StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[Msg->State]));
+       StrBufPrintf(IO->ErrMsg, "Connection failure: %s while talking to %s",
+                    ReadErrors[Msg->State].Key,
+                    Msg->mx_host);
+
        return FailOneAttempt(IO);
 }
 eNextState SMTP_C_DNSFail(AsyncIO *IO)