]> granicus.if.org Git - mutt/commitdiff
Fix #718.
authorPaul Walker <paul@black-sun.demon.co.uk>
Mon, 11 Nov 2002 19:46:29 +0000 (19:46 +0000)
committerPaul Walker <paul@black-sun.demon.co.uk>
Mon, 11 Nov 2002 19:46:29 +0000 (19:46 +0000)
commands.c
protos.h
sendlib.c

index c86d1565aa93b3b6f24a577c1011dac601650c86..88cd38f2e828ae736908e6f26735edf589e292a3 100644 (file)
@@ -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)
index f2f73e7da8bbd9ab11eecde9e7f0f500a98c33cb..f8e20afc0560a0c7111aff0d35bcd7c4d88f4a57 100644 (file)
--- 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 *);
index ebd82bc0f2971deb07e172d0a7e09b81ac842c3f..5df8368b93787d314227ef6a5fa2f33d26c78543 100644 (file)
--- 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; i<Context->msgcount; 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;
 }