updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / mutt-sendbox / mutt-sendbox-bounce.patch
blobbd73b7dbbc2a250ed3e2b2ad1495fcb3011afe49
1 Add support for sendbox (bounce path)
3 This patch adds support for "sendbox" to the bounce path.
4 Additionally a bug is fixed: previously there would be no warning or error
5 emitted if mutt failed to create the temporary file when bouncing a message.
7 Signed-off-by: Aron Griffis <agrif...@n01se.net>
9 diff -r a1d30c527520 -r 0069fde2f491 sendlib.c
10 --- a/sendlib.c Tue Apr 28 11:17:31 2009 -0400
11 +++ b/sendlib.c Tue Apr 28 11:17:31 2009 -0400
12 @@ -2669,6 +2669,13 @@
13 FILE *f;
14 char date[SHORT_STRING], tempfile[_POSIX_PATH_MAX];
15 MESSAGE *msg = NULL;
16 + int ch_flags;
17 + char *msgid_str;
18 +#ifdef USE_SENDBOX
19 + struct mutt_message_handle *mh = NULL;
20 + CONTEXT sctx;
21 + MESSAGE *smsg = NULL;
22 +#endif
24 if (!h)
26 @@ -2685,28 +2692,65 @@
28 if (!fp) fp = msg->fp;
30 - mutt_mktemp (tempfile, sizeof (tempfile));
31 - if ((f = safe_fopen (tempfile, "w")) != NULL)
32 + ch_flags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
33 + if (!option (OPTBOUNCEDELIVERED))
34 + ch_flags |= CH_WEED_DELIVERED;
36 + /* create a message which is the original message with Resent
37 + * header fields prepended. For sendmail and smtp, the message is
38 + * a tempfile. For sendbox, it's a newly created message in the
39 + * Sendbox folder.
40 + */
41 +#ifdef USE_SENDBOX
42 + if (Sendbox)
44 - int ch_flags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
45 - char* msgid_str;
47 - if (!option (OPTBOUNCEDELIVERED))
48 - ch_flags |= CH_WEED_DELIVERED;
50 - fseeko (fp, h->offset, 0);
51 - fprintf (f, "Resent-From: %s", resent_from);
52 - fprintf (f, "\nResent-%s", mutt_make_date (date, sizeof(date)));
53 - msgid_str = mutt_gen_msgid();
54 - fprintf (f, "Resent-Message-ID: %s\n", msgid_str);
55 - fputs ("Resent-To: ", f);
56 - mutt_write_address_list (to, f, 11, 0);
57 - mutt_copy_header (fp, h, f, ch_flags, NULL);
58 - fputc ('\n', f);
59 - mutt_copy_bytes (fp, f, h->content->length);
60 + mh = mutt_start_message (Sendbox, h, &sctx, &smsg, 1);
61 + if (!mh)
62 + {
63 + ret = -1;
64 + goto close_msg;
65 + }
66 + f = smsg->fp;
68 + /* Resent-To: headers will be unioned by the MTA to
69 + * determine the recipient, so weed any old ones
70 + */
71 + ch_flags |= CH_WEED_RESENT;
72 + }
73 + else
74 +#endif
75 + {
76 + mutt_mktemp (tempfile, sizeof(tempfile));
77 + if ((f = safe_fopen (tempfile, "w")) == NULL)
78 + {
79 + mutt_perror (tempfile);
80 + ret = -1;
81 + goto close_msg;
82 + }
83 + }
85 + /* prepend the Resent header fields */
86 + fprintf (f, "Resent-From: %s", resent_from);
87 + fprintf (f, "\nResent-%s", mutt_make_date (date, sizeof(date)));
88 + msgid_str = mutt_gen_msgid();
89 + fprintf (f, "Resent-Message-ID: %s\n", msgid_str);
90 + FREE (&msgid_str);
91 + fputs ("Resent-To: ", f);
92 + mutt_write_address_list (to, f, 11, 0);
94 + /* copy original message */
95 + fseeko (fp, h->offset, 0);
96 + mutt_copy_header (fp, h, f, ch_flags, NULL);
97 + fputc ('\n', f);
98 + mutt_copy_bytes (fp, f, h->content->length);
100 +#ifdef USE_SENDBOX
101 + if (Sendbox)
102 + ret = mutt_finish_message (mh, Sendbox, h, &sctx, &smsg, 1);
103 + else
104 +#endif
106 safe_fclose (&f);
107 - FREE (&msgid_str);
109 #if USE_SMTP
110 if (SmtpUrl)
111 ret = mutt_smtp_send (env_from, to, NULL, NULL, tempfile,
112 @@ -2717,6 +2724,7 @@
113 h->content->encoding == ENC8BIT);
116 +close_msg:
117 if (msg)
118 mx_close_message (&msg);