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 @@
14 char date[SHORT_STRING], tempfile[_POSIX_PATH_MAX];
19 + struct mutt_message_handle *mh = NULL;
21 + MESSAGE *smsg = NULL;
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
44 - int ch_flags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
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);
59 - mutt_copy_bytes (fp, f, h->content->length);
60 + mh = mutt_start_message (Sendbox, h, &sctx, &smsg, 1);
68 + /* Resent-To: headers will be unioned by the MTA to
69 + * determine the recipient, so weed any old ones
71 + ch_flags |= CH_WEED_RESENT;
76 + mutt_mktemp (tempfile, sizeof(tempfile));
77 + if ((f = safe_fopen (tempfile, "w")) == NULL)
79 + mutt_perror (tempfile);
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);
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);
98 + mutt_copy_bytes (fp, f, h->content->length);
102 + ret = mutt_finish_message (mh, Sendbox, h, &sctx, &smsg, 1);
111 ret = mutt_smtp_send (env_from, to, NULL, NULL, tempfile,
112 @@ -2717,6 +2724,7 @@
113 h->content->encoding == ENC8BIT);
118 mx_close_message (&msg);