]> code.citadel.org Git - citadel.git/commitdiff
Original message is now attached to smtp bounces.
authorArt Cancro <ajc@citadel.org>
Mon, 19 Mar 2007 14:52:21 +0000 (14:52 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 19 Mar 2007 14:52:21 +0000 (14:52 +0000)
citadel/serv_smtp.c

index fdc1a217b4dc0e1a403a86501001c560762288c5..a6bae93427cd92253bc9841bd23eaac4fa02ef2f 100644 (file)
@@ -1370,6 +1370,9 @@ void smtp_do_bounce(char *instr) {
        struct recptypes *valid;
        int successful_bounce = 0;
        static int seq = 0;
+       char *omsgtext;
+       size_t omsgsize;
+       long omsgid = (-1);
 
        lprintf(CTDL_DEBUG, "smtp_do_bounce() called\n");
        strcpy(bounceto, "");
@@ -1390,6 +1393,8 @@ void smtp_do_bounce(char *instr) {
                give_up = 1;
        }
 
+       /* Start building our bounce message */
+
        bmsg = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage));
        if (bmsg == NULL) return;
        memset(bmsg, 0, sizeof(struct CtdlMessage));
@@ -1403,7 +1408,6 @@ void smtp_do_bounce(char *instr) {
         bmsg->cm_fields['U'] = strdup("Delivery Status Notification (Failure)");
        bmsg->cm_fields['M'] = malloc(1024);
 
-
         strcpy(bmsg->cm_fields['M'], "Content-type: multipart/mixed; boundary=\"");
         strcat(bmsg->cm_fields['M'], boundary);
         strcat(bmsg->cm_fields['M'], "\"\r\n");
@@ -1444,6 +1448,10 @@ void smtp_do_bounce(char *instr) {
                        strcpy(bounceto, addr);
                }
 
+               if (!strcasecmp(key, "msgid")) {
+                       omsgid = atol(addr);
+               }
+
                if (
                   (!strcasecmp(key, "local"))
                   || (!strcasecmp(key, "remote"))
@@ -1475,14 +1483,32 @@ void smtp_do_bounce(char *instr) {
                }
        }
 
-       /* Attach the original message 
-        strcat(bmsg->cm_fields['M'], "--");
-        strcat(bmsg->cm_fields['M'], boundary);
-        strcat(bmsg->cm_fields['M'], "\r\n");
-        strcat(bmsg->cm_fields['M'], "Content-type: application/octet-stream\r\n\r\n");
-        strcat(bmsg->cm_fields['M'], "all your message are belong to FIXME\r\n");
-       */
-
+       /* Attach the original message */
+       if (omsgid >= 0) {
+               strcat(bmsg->cm_fields['M'], "--");
+               strcat(bmsg->cm_fields['M'], boundary);
+               strcat(bmsg->cm_fields['M'], "\r\n");
+               strcat(bmsg->cm_fields['M'], "Content-type: message/rfc822\r\n");
+               strcat(bmsg->cm_fields['M'], "Content-Transfer-Encoding: 7bit\r\n");
+               strcat(bmsg->cm_fields['M'], "Content-Disposition: inline\r\n");
+               strcat(bmsg->cm_fields['M'], "\r\n");
+       
+               CC->redirect_buffer = malloc(SIZ);
+               CC->redirect_len = 0;
+               CC->redirect_alloc = SIZ;
+               CtdlOutputMsg(omsgid, MT_RFC822, HEADERS_ALL, 0, 1, NULL);
+               omsgtext = CC->redirect_buffer;
+               omsgsize = CC->redirect_len;
+               CC->redirect_buffer = NULL;
+               CC->redirect_len = 0;
+               CC->redirect_alloc = 0;
+               bmsg->cm_fields['M'] = realloc(bmsg->cm_fields['M'],
+                               (strlen(bmsg->cm_fields['M']) + omsgsize + 1024) );
+               strcat(bmsg->cm_fields['M'], omsgtext);
+               free(omsgtext);
+       }
+
+       /* Close the multipart MIME scope */
         strcat(bmsg->cm_fields['M'], "--");
         strcat(bmsg->cm_fields['M'], boundary);
         strcat(bmsg->cm_fields['M'], "--\r\n");