1

I was trying to send a mail from the shell script using the command

mailx -s "TEST MAIL" -c "user_name ..." user<message.txt

but it generates an error as unrecognized option -c ,the same happens if i use -b as a option for blind copy, so what options do i need to use for cc and bcc here ???

LocalHost
  • 489
  • See https://unix.stackexchange.com/a/445229/117549 and https://unix.stackexchange.com/a/285415/117549; one of those may work – Jeff Schaller Dec 17 '18 at 15:08

1 Answers1

4

Debian and Ubuntu have replaced Heirloom mailx with s-nail mailx. Both support the -b and -c options. But there are other mailx commands from other packages which do not.

I suspect that you, too, are unknowingly using the GNU Mailutils mailx or the NMH mailx. The latter re-spells the -c option as -cc but has no equivalent for -b. The former has no direct equivalents for either, requiring that headers be injected using a generic mechanism. (Note that, strictly speaking, -b and -c control envelope not headers, although the distinction between them is blurry at the level of mailx.)

Further reading

JdeBP
  • 68,745
  • See the thing is none of the mail service was pre installed on ubuntu,I explicitly installed gnu mailutils ,so what you suggest in my case ???? – LocalHost Dec 17 '18 at 15:45