SMTP-Client: use the right pointer to destruct the message.
[citadel.git] / citadel / modules / smtp / serv_smtpeventclient.c
index e85dfe411f1f96c2a90b6c4cd1cb66faf2dcc043..fbcf67c2ced45a0c8c56f8ed27efe74831800b8c 100644 (file)
@@ -177,7 +177,7 @@ eNextState FinalizeMessageSend_DB(AsyncIO *IO)
        Msg->MyQItem->QueMsgID = -1;
 
        if (Msg->IDestructQueItem)
-               smtpq_do_bounce(Msg->MyQItem, Msg->msgtext);
+               smtpq_do_bounce(Msg->MyQItem, Msg->msgtext, Msg->pCurrRelay);
 
        if (Msg->nRemain > 0)
        {
@@ -587,8 +587,10 @@ void smtp_try_one_queue_entry(OneQueItem *MyQItem,
        if (KeepMsgText) Msg->msgtext = MsgText;
        else             Msg->msgtext = NewStrBufDup(MsgText);
 
-       if (smtp_resolve_recipients(Msg)) {
-
+       if (((!MyQItem->HaveRelay ||
+             (MyQItem->URL != NULL)) &&
+            smtp_resolve_recipients(Msg)))
+       {
                safestrncpy(
                        ((CitContext *)Msg->IO.CitContext)->cs_host,
                        Msg->node,
@@ -619,11 +621,12 @@ void smtp_try_one_queue_entry(OneQueItem *MyQItem,
                /* No recipients? well fail then. */
                if (Msg->MyQEntry != NULL) {
                        Msg->MyQEntry->Status = 5;
-                       StrBufPlain(Msg->MyQEntry->StatusMessage,
-                                   HKEY("Invalid Recipient!"));
+                       if (StrLength(Msg->MyQEntry->StatusMessage) == 0)
+                               StrBufPlain(Msg->MyQEntry->StatusMessage,
+                                           HKEY("Invalid Recipient!"));
                }
                FinalizeMessageSend_DB(&Msg->IO);
-               DeleteSmtpOutMsg(&Msg->IO);
+               DeleteSmtpOutMsg(Msg);
        }
 }