From d69af6ef33db4025a65188a6cc97af87516a79cc Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Mon, 11 Nov 2002 19:46:29 +0000 Subject: [PATCH] Fix #718. --- commands.c | 6 ++++-- protos.h | 2 +- sendlib.c | 25 ++++++++++++++++--------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/commands.c b/commands.c index c86d1565..88cd38f2 100644 --- a/commands.c +++ b/commands.c @@ -295,9 +295,11 @@ void ci_bounce_message (HEADER *h, int *redraw) return; } - mutt_bounce_message (NULL, h, adr); + rc = mutt_bounce_message (NULL, h, adr); rfc822_free_address (&adr); - mutt_message (h ? _("Message bounced.") : _("Messages bounced.")); + /* If no error, or background, display message. */ + if ((rc == 0) || (rc == S_BKG)) + mutt_message (h ? _("Message bounced.") : _("Messages bounced.")); } static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags) diff --git a/protos.h b/protos.h index f2f73e7d..f8e20afc 100644 --- a/protos.h +++ b/protos.h @@ -147,7 +147,7 @@ void mutt_attach_init (BODY *); void mutt_block_signals (void); void mutt_block_signals_system (void); void mutt_body_handler (BODY *, STATE *); -void mutt_bounce_message (FILE *fp, HEADER *, ADDRESS *); +int mutt_bounce_message (FILE *fp, HEADER *, ADDRESS *); void mutt_buffy (char *, size_t); int mutt_buffy_list (void); void mutt_canonical_charset (char *, size_t, const char *); diff --git a/sendlib.c b/sendlib.c index ebd82bc0..5df8368b 100644 --- a/sendlib.c +++ b/sendlib.c @@ -2215,24 +2215,26 @@ void mutt_unprepare_envelope (ENVELOPE *env) rfc2047_decode (&env->subject); } -static void _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *resent_from, +static int _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *resent_from, ADDRESS *env_from) { - int i; + int i, ret = 0; FILE *f; char date[SHORT_STRING], tempfile[_POSIX_PATH_MAX]; MESSAGE *msg = NULL; if (!h) { + /* Try to bounce each message out, aborting if we get any failures. */ for (i=0; imsgcount; i++) if (Context->hdrs[i]->tagged) - _mutt_bounce_message (fp, Context->hdrs[i], to, resent_from, env_from); - return; + ret |= _mutt_bounce_message (fp, Context->hdrs[i], to, resent_from, env_from); + return ret; } + /* If we failed to open a message, return with error */ if (!fp && (msg = mx_open_message (Context, h->msgno)) == NULL) - return; + return -1; if (!fp) fp = msg->fp; @@ -2255,19 +2257,22 @@ static void _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char * mutt_copy_bytes (fp, f, h->content->length); fclose (f); - mutt_invoke_sendmail (env_from, to, NULL, NULL, tempfile, - h->content->encoding == ENC8BIT); + ret = mutt_invoke_sendmail (env_from, to, NULL, NULL, tempfile, + h->content->encoding == ENC8BIT); } if (msg) mx_close_message (&msg); + + return ret; } -void mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to) +int mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to) { ADDRESS *from; const char *fqdn = mutt_fqdn (1); char resent_from[STRING]; + int ret; resent_from[0] = '\0'; from = mutt_default_from (); @@ -2279,9 +2284,11 @@ void mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to) rfc822_write_address (resent_from, sizeof (resent_from), from); - _mutt_bounce_message (fp, h, to, resent_from, from); + ret = _mutt_bounce_message (fp, h, to, resent_from, from); rfc822_free_address (&from); + + return ret; } -- 2.40.0