Added message-id to the list of fields CtdlOutputMsg() can potentially return to...
[citadel.git] / citadel / modules / smtp / smtp_util.c
index adb6fa86d48a12bbce2eb66bf2aa3ac4b80c9f66..8609f91133bcd86e71d7c0f73ebeec569fe7fc8e 100644 (file)
  * The VRFY and EXPN commands have been removed from this implementation
  * because nobody uses these commands anymore, except for spammers.
  *
- * Copyright (c) 1998-2009 by the citadel.org team
+ * Copyright (c) 1998-2012 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
+ *  This program is open source software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 3.
+ *  
+ *  
  *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  
+ *  
+ *  
  */
 
 #include "sysdep.h"
@@ -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");
 }