Added message-id to the list of fields CtdlOutputMsg() can potentially return to...
[citadel.git] / citadel / modules / smtp / smtp_util.c
index 861ee97636efe375be66af2fe15278f1a253832e..8609f91133bcd86e71d7c0f73ebeec569fe7fc8e 100644 (file)
@@ -94,7 +94,7 @@ const char *smtp_get_Recipients(void)
 
        if (sSMTP == NULL)
                return NULL;
-       else return sSMTP->from;
+       else return ChrPtr(sSMTP->from);
 }
 
 
@@ -119,7 +119,7 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
        time_t submitted = 0L;
        struct CtdlMessage *bmsg = NULL;
        int give_up = 0;
-       struct recptypes *valid;
+       recptypes *valid;
        int successful_bounce = 0;
        static int seq = 0;
        StrBuf *BounceMB;
@@ -161,10 +161,10 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
        bmsg->cm_magic = CTDLMESSAGE_MAGIC;
        bmsg->cm_anon_type = MES_NORMAL;
        bmsg->cm_format_type = FMT_RFC822;
-       bmsg->cm_fields['A'] = strdup("Citadel");
-       bmsg->cm_fields['O'] = strdup(MAILROOM);
-       bmsg->cm_fields['N'] = strdup(config.c_nodename);
-       bmsg->cm_fields['U'] = strdup("Delivery Status Notification (Failure)");
+       CM_SetField(bmsg, eAuthor, HKEY("Citadel"));
+       CM_SetField(bmsg, eOriginalRoom, HKEY(MAILROOM));
+       CM_SetField(bmsg, eNodeName, CFG_KEY(c_nodename));
+       CM_SetField(bmsg, eMsgSubject, HKEY("Delivery Status Notification (Failure)"));
        StrBufAppendBufPlain(
                BounceMB,
                HKEY("Content-type: multipart/mixed; boundary=\""), 0);
@@ -271,7 +271,8 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
                        CtdlOutputMsg(omsgid,
                                      MT_RFC822,
                                      HEADERS_ALL,
-                                     0, 1, NULL, 0);
+                                     0, 1, NULL, 0,
+                                     NULL, NULL, NULL);
 
                        StrBufAppendBuf(BounceMB, CC->redirect_buffer, 0);
                        FreeStrBuf(&CC->redirect_buffer);
@@ -285,9 +286,8 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
        StrBufAppendBufPlain(BounceMB, HKEY("--"), 0);
        StrBufAppendBuf(BounceMB, boundary, 0);
        StrBufAppendBufPlain(BounceMB, HKEY("--\r\n"), 0);
-       if (bmsg->cm_fields['A'] != NULL)
-               free(bmsg->cm_fields['A']);
-       bmsg->cm_fields['A'] = SmashStrBuf(&BounceMB);
+       CM_SetAsFieldSB(bmsg, eMesageText, &BounceMB);
+
        /* Deliver the bounce if there's anything worth mentioning */
        syslog(LOG_DEBUG, "num_bounces = %d\n", num_bounces);
        if (num_bounces > 0) {
@@ -319,6 +319,6 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
                }
        }
        FreeStrBuf(&boundary);
-       CtdlFreeMessage(bmsg);
+       CM_Free(bmsg);
        syslog(LOG_DEBUG, "Done processing bounces\n");
 }