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