I have a script that it sends emails to various recipients using mailx , but some of the recipients should be sent as BCC, but ~b flag when used in the following line, does not put the gmail address as BCC:
echo "node $output is down" | mailx -s "$output not pinging" sadf@xyz.com ~b sadf@gmail.com
Both email addresses appear on the TO: field of the outlook message
Assuming that flag is supported in your implementation of mailx , I'm almost certain it should be -b rather than ~b . Certainly I just checked the Solaris man page for mailx , and it lists the BCC flag as being -b . I've never, ever heard of any command taking flags with a tilde rather than a dash. You should also probably put it before the recipient's address, and not after.
Did you also move the BCC flag and its address to before the recipient address, or are you still adding it afterwards ? In general you'll want all parameters to be listed before the recipient.
The best thing then would be to check your mail server's log, and see if it actually did send it and what response it got if it did. If you're on a Solaris 10 system that's using a default Sendmail configuration, then this will most likely be writing its log entries to /var/adm/messages .