I'm trying to send unix mail (heirloom-mailx) via bcc.

$ mail -V
12.5 6/20/10

My MTA is exim, which sends via Gmail SMTP.

I can execute the following:

echo -e "body" | mail -s 'subject' -b [email protected],[email protected] [email protected]

All addresses receive the email, however the bcc is not hidden. i.e. in the email to [email protected], I still see:

To: [email protected]
Bcc: [email protected],[email protected]

How can I make mail send bcc properly?

  • I found this thread on SO: stackoverflow.com/questions/14521280/…
    – slm
    Commented Oct 22, 2013 at 5:30
  • @slm Thanks. I did come across a few other posts complaining that -b didn't work, but they seemed to suggest that it wouldn't send at all, rather than the problem I have. However, if I don't get a response here, I'll check out some of the other mail programs.
    – Sparhawk
    Commented Oct 22, 2013 at 5:32
  • Could you name MTA server you use? [sendmail/postfix/exim/...] I think that many servers strip Bcc: headers.
    – AnFi
    Commented Oct 22, 2013 at 5:36
  • I'm using exim, which sends via gmail smtp.
    – Sparhawk
    Commented Oct 22, 2013 at 5:39

2 Answers 2


heirloom-mailx hardcodes the options to pass to /usr/sbin/sendmail, and unfortunately the ones it passes don't make Bcc: headers work right in exim. That isn't really fixable, without patching and recompiling it. (You need to have it add -t to the arguments, and then either not pass the list of email addresses or alternatively set extract_addresses_remove_arguments = false in your exim config).

There is an easier solution: just have it send via SMTP. You do this by setting the smtp option, and since you've got a local MTA running, you should be able to set it to localhost. You can test like this:

$ mail -S smtp=localhost -s 'test message' -b [email protected] [email protected]
la la la

If that works, you can put the smtp option in /etc/nail.rc (system-wide) or ~/.mailrc (per-user). Note that nail.rc, with an n, is not a typo.

  • Oh! That was surprisingly straightforward. I previously set up gmail smtp with sudo dpkg-reconfigure exim4-config and modifying /etc/exim4/passwd.client. How should I revert these changes, and how do they relate to /etc/nail.rc?
    – Sparhawk
    Commented Oct 23, 2013 at 10:50
  • @Sparhawk There is no reason to revert your exim4-config changes. nail.rc just configures heirloom-mailx, and in this case you're just configuring it to speak to your local exim a different way (over a TCP connection to localhost vs. running /usr/sbin/sendmail)
    – derobert
    Commented Oct 23, 2013 at 10:52

If using GNU mailx from mailutils package, BCC and CC can be added by using the --append option to add header variables, like so:

$ echo -e "body text line1\nline2\n\nsent at: $(date)" | mailx --append='FROM:Foghorn Leghorn <[email protected]>' --append='BCC:[email protected]' -s "test subject" -- [email protected] [email protected] [email protected]

Also note how the above command uses the header variable for the FROM address.

  • Hi, I'm not really in the position to test this any more, but thank you for answering (+1)!
    – Sparhawk
    Commented May 22, 2018 at 4:33
  • @Sparhawk: that's okay, I do test all my responses :) Commented Sep 8, 2018 at 15:44
  • I more meant that for me to +1, I really should verify that "this answer is useful [to me]", but since I cannot, I gave you the benefit of the doubt.
    – Sparhawk
    Commented Sep 8, 2018 at 23:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .