0

I'm trying to BCC e-mails through unix using the following command.

echo "E-mail message" | mailx -r Senders@Address.com -s "E-mails Subject" ~b BCC_Receiver@Address.com

But I get the error ~b... User unknown.

If I use -b instead of ~b, I get the error illegal option -- b

If I use mail instead of mailx, I get exactly the same erros.

However, when I try it interactively in the following way, it works.

mail -r Senders@Address.com -s Subject Receivers@Address.com
~b BCC_Receiver
E-mail message
.
CC:

I'd like to make this work in a single command. How can I do this?

When I type uname -a, this is the output: s00va9939577 1 7 00CD96834C00.

  • I'm really new to UNIX, so I'm expecting my question to be missing some important information (for instance which version I am on - I don't know how to check, if you need this, please tell me how I can find it out). Please ask anything you want to know. I also ask that whoever is qualified enough tags my question appropriately. Thank you in advance. – Noob May 25 '16 at 13:18
  • You might have seen this from a book with a printing error or some bad UTF code. The ~b refers to the home directory of a user named b. – Otheus May 25 '16 at 13:25
  • 1
    You need to run the command man mailx to read the documentation for the mailx command. The "man page" will tell you what are the valid options. – glenn jackman May 25 '16 at 13:29
  • 1
    It might also be useful to run the command uname -a and post the output in your answer so we can have an idea about what kind of system you're running on. – glenn jackman May 25 '16 at 13:30
  • 1
    @Noob, right, sorry. The ~b doesn't work on the command line. The shell expands it into a directory, which mailx then treates as a filename argument. But, the user doesn't exist, so the shell kindly refuses to run the command. – Otheus May 25 '16 at 20:52
3

The -b option, to specify addresses on the command line, does not appear to be supported on your version.

Your second, interactive example works because mailx recognises it as tilde escape. These have to appear as the first thing on the line in the message body, rather than on the command line. They're in the specification, so they are more widely supported.

The following commands can be entered only from input mode, by beginning a line with the escape character (by default, <tilde> ( '˜' ))

[...]

~b name . . .

Add the names to the blind carbon copy (Bcc) list.

0

there is no ~b used as a switch to mailx on any unix platform that I know of. Correct command should look something like this:

echo -e "email message body" | mail -s 'subject' -b bcc_address_1@server1.com,bcc_address_2@server2.com visible_to_address@server.com
  • The OP did mention trying -b and getting an error... – Stephen Kitt May 25 '16 at 13:25
  • MelBurslan, as @StephenKitt pointed out. I already tried this and I get the error described in the question. – Noob May 25 '16 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.