]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/smtp/serv_smtpeventclient.c
Read multiline SMTP-Replies; we need to analyze all of them to detect the proper...
[citadel.git] / citadel / modules / smtp / serv_smtpeventclient.c
index bb11522c19eb29af47a00086fd34f605803c57bc..be573d73a33ca23bbd7766a5cb008133a1cbe856 100644 (file)
@@ -108,7 +108,8 @@ ConstStr SMTPStates[] = {
 void SetSMTPState(AsyncIO *IO, smtpstate State)
 {
        CitContext* CCC = IO->CitContext;
-       memcpy(CCC->cs_clientname, SMTPStates[State].Key, SMTPStates[State].len + 1);
+       if (CCC != NULL)
+               memcpy(CCC->cs_clientname, SMTPStates[State].Key, SMTPStates[State].len + 1);
 }
 
 int SMTPClientDebugEnabled = 0;
@@ -126,6 +127,7 @@ void DeleteSmtpOutMsg(void *v)
                Msg->HostLookup.DNSReplyFree(Msg->HostLookup.VParsedDNSReply);
        FreeURL(&Msg->Relay);
        FreeStrBuf(&Msg->msgtext);
+       FreeStrBuf(&Msg->MultiLineBuf);
        FreeAsyncIOContents(&Msg->IO);
        memset (Msg, 0, sizeof(SmtpOutMsg)); /* just to be shure... */
        free(Msg);
@@ -154,7 +156,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 +184,7 @@ eNextState FinalizeMessageSend_DB(AsyncIO *IO)
                   Msg->user,
                   Msg->node,
                   Msg->name,
-                  ChrPtr(Msg->MyQEntry->StatusMessage));
+                  ChrPtr(StatusMessage));
 
 
        Msg->IDestructQueItem = DecreaseQReference(Msg->MyQItem);
@@ -246,7 +255,7 @@ eNextState Terminate(AsyncIO *IO)
 eNextState FinalizeMessageSend(SmtpOutMsg *Msg)
 {
        /* hand over to DB Queue */
-       return QueueDBOperation(&Msg->IO, FinalizeMessageSend_DB);
+       return EventQueueDBOperation(&Msg->IO, FinalizeMessageSend_DB);
 }
 
 eNextState FailOneAttempt(AsyncIO *IO)
@@ -855,7 +864,16 @@ eReadState SMTP_C_ReadServerStatus(AsyncIO *IO)
                        if (StrLength(IO->IOBuf) < 4)
                                continue;
                        if (ChrPtr(IO->IOBuf)[3] == '-')
+                       {
+                               SmtpOutMsg *Msg;
+                               Msg = (SmtpOutMsg *)IO->Data;
+                               if (Msg->MultiLineBuf == NULL)
+                                       Msg->MultiLineBuf = NewStrBuf ();
+                               else
+                                       StrBufAppendBufPlain(Msg->MultiLineBuf, HKEY("\n"), 0);
+                               StrBufAppendBuf(Msg->MultiLineBuf, IO->IOBuf, 0);
                                Finished = eBufferNotEmpty;
+                       }
                        else
                                return Finished;
                        break;