'Linux mail command to bcc multiple addresses?

I am using linux mail command to send an automated email to a bunch of people once per week. I want each one of the recipients to be BCC'ed.

I am trying this command:

mail -v -s "Email Subject" -b [email protected], [email protected], [email protected], [email protected] -- -f [email protected] < /pathTo/dir/emailText.txt

But get this error:

You must specify direct recipients with -s, -c, or -b.


Solution 1:[1]

you need to put them all in a single argument by quoting it.

mail -v -s "Email Subject" -b '[email protected], [email protected], [email protected], [email protected]' -- -f [email protected] < /pathTo/dir/emailText.txt

Solution 2:[2]

It seems there are multiple versions of the mail command.

mail (GNU Mailutils) 3.7 has an append option to add headers and values directly without piping them in. Just add the headers you need there, e.g. bcc:

echo "Just testing my sendmail" | mail -s "Sendmail test" [email protected] --append=Bcc:[email protected],[email protected]

How to send mail through BCC in UNIX

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Barmar
Solution 2 poleguy