diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-11-07 22:19:45 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-11-07 22:19:45 +0000 |
commit | 283cc465b8a09272d2c15e33e026b1d32eb312ae (patch) | |
tree | 6adb24f96ab9e5a7a152dbfedb8b3564510c9c62 /sendlib.c | |
parent | 538c400f14c9ceeb83a3836d622ee968a92eb602 (diff) |
Rewriting lots of the recvattach code.
Diffstat (limited to 'sendlib.c')
-rw-r--r-- | sendlib.c | 58 |
1 files changed, 31 insertions, 27 deletions
@@ -1811,49 +1811,53 @@ void mutt_prepare_envelope (ENVELOPE *env) if (!env->message_id) env->message_id = mutt_gen_msgid (); } - -static void _mutt_bounce_message (HEADER *h, ADDRESS *to, const char *resent_from) + +static void _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *resent_from) { int i; FILE *f; char date[SHORT_STRING], tempfile[_POSIX_PATH_MAX]; - MESSAGE *msg; + MESSAGE *msg = NULL; if (!h) { for (i=0; i<Context->msgcount; i++) if (Context->hdrs[i]->tagged) - _mutt_bounce_message (Context->hdrs[i], to, resent_from); + _mutt_bounce_message (fp, Context->hdrs[i], to, resent_from); return; } - if ((msg = mx_open_message (Context, h->msgno)) != NULL) + if (!fp && (msg = mx_open_message (Context, h->msgno)) == NULL) + return; + + if (!fp) fp = msg->fp; + + mutt_mktemp (tempfile); + if ((f = safe_fopen (tempfile, "w")) != NULL) { - mutt_mktemp (tempfile); - if ((f = safe_fopen (tempfile, "w")) != NULL) - { - int ch_flags = CH_XMIT | CH_NONEWLINE; - - if (!option (OPTBOUNCEDELIVERED)) - ch_flags |= CH_WEED_DELIVERED; - - fseek (msg->fp, h->offset, 0); - mutt_copy_header (msg->fp, h, f, ch_flags, NULL); - fprintf (f, "Resent-From: %s", resent_from); - fprintf (f, "\nResent-%s", mutt_make_date (date, sizeof(date))); - fputs ("Resent-To: ", f); - mutt_write_address_list (to, f, 11); - fputc ('\n', f); - mutt_copy_bytes (msg->fp, f, h->content->length); - fclose (f); + int ch_flags = CH_XMIT | CH_NONEWLINE; + + if (!option (OPTBOUNCEDELIVERED)) + ch_flags |= CH_WEED_DELIVERED; + + fseek (fp, h->offset, 0); + mutt_copy_header (fp, h, f, ch_flags, NULL); + fprintf (f, "Resent-From: %s", resent_from); + fprintf (f, "\nResent-%s", mutt_make_date (date, sizeof(date))); + fputs ("Resent-To: ", f); + mutt_write_address_list (to, f, 11); + fputc ('\n', f); + mutt_copy_bytes (fp, f, h->content->length); + fclose (f); - mutt_invoke_sendmail (to, NULL, NULL, tempfile, h->content->encoding == ENC8BIT); - } - mx_close_message (&msg); + mutt_invoke_sendmail (to, NULL, NULL, tempfile, h->content->encoding == ENC8BIT); } + + if (msg) + mx_close_message (&msg); } -void mutt_bounce_message (HEADER *h, ADDRESS *to) +void mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to) { ADDRESS *from; const char *fqdn = mutt_fqdn (1); @@ -1870,7 +1874,7 @@ void mutt_bounce_message (HEADER *h, ADDRESS *to) rfc822_write_address (resent_from, sizeof (resent_from), from); rfc822_free_address (&from); - _mutt_bounce_message (h, to, resent_from); + _mutt_bounce_message (fp, h, to, resent_from); } |