$sendmail option unconditionally and wrongly uses --

Pretty old bug, looking at the code it is still there

https://bugs.debian.org/509581

The $sendmail option is described as follows:

  # Name: sendmail
  # Type: path
  # Default: "/usr/sbin/sendmail -oem -oi"
  #
  #
  # Specifies the program and arguments used to deliver mail sent by Mutt.
  # Mutt expects that the specified program interprets additional
  # arguments as recipient addresses.

I need to add an "always-bcc" address, so I tried

  set sendmail="/usr/sbin/sendmail -oem -oi madduck+spool@madduck.net"

and also

  set sendmail="/usr/sbin/sendmail -oem -oi -- madduck+spool@madduck.net"

It turns out, however, that mutt appends not only additional arguments (recipients), but also unconditionally a '--'. In the above cases, this yields:

  /usr/sbin/sendmail -oem -oi madduck+spool@madduck.net -- foo@bar.com
  /usr/sbin/sendmail -oem -oi -- madduck+spool@madduck.net -- foo@bar.com

Both are wrong. mutt should probably not append -- if it's already contained in $sendmail.


Proposed patch for the code at the time was the following, I think it is still applicable with a small adjustment:

--- sendlib.c-orig  2009-01-20 22:57:28.000000000 +0000
+++ sendlib.c   2009-01-20 22:57:57.000000000 +0000
@@ -2206,7 +2206,11 @@
     args = add_option (args, &argslen, &argsmax, "-R");
     args = add_option (args, &argslen, &argsmax, DsnReturn);
   }
+  if ( strstr( args, "--" ) == NULL )
+  {
+    /* Only append "--" if not already present. */
   args = add_option (args, &argslen, &argsmax, "--");
+  }
   args = add_args (args, &argslen, &argsmax, to);
   args = add_args (args, &argslen, &argsmax, cc);
   args = add_args (args, &argslen, &argsmax, bcc);