'How to send mail through BCC in UNIX
I am trying to send mail through BCC,CC and TO list. CC and TO are working fine but getting error from BCC as mailx: illegal option -- b
Here is my syntax
(echo "$MSG_BODY";)|mailx -r "[email protected]" -s "$MSG_SUB" -b $BCC_LIST -c $CC_LIST $TO_LIST
Please help me out.
Solution 1:[1]
If you have sendmail utility, use can use it to send the mails through BCC:
(
echo "MIME-Version: 1.0
From: [email protected]
To: $TO_LIST
Cc: $CC_LIST
Bcc: $BCC_LIST
Subject: $MSG_SUB
Content-Type: text/html
"
echo "$MSG_BODY"
) | /usr/sbin/sendmail -t
Please let me know if it helps.
Solution 2:[2]
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]
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 | User123 |
| Solution 2 | poleguy |
