11

I want to send email from HP unix using mailx command. I have to include cc and bcc in my email and have to use the specific email address as the sender.

But -r (which is to define the sender's email address) will disalbe ~ commands so if i have to define the sender's email address, i cannot use ~c and ~b commands for cc and bcc.

Is there any work around???? cos these are the requirements from the user.

Thanks.

Kyaw Lwin Phyo
  • 121
  • 1
  • 1
  • 6
  • can't you embed the cc and bcc in the header(ish) text that is transmitted, just like 'subject:', etc? Good luck. – shellter Apr 11 '12 at 04:51
  • what i tried to do was to write the cc and bcc into a file along with the email message. then set up the mailx -r. When the email has been sent, ~c cc@address.com and ~b bcc@address.com are included as the email body, not as cc and bcc. Thanks – Kyaw Lwin Phyo Apr 11 '12 at 05:42

2 Answers2

16

Just re-order the arguments to mailx command. That would give the desired result

$ echo "something" | mailx -s "subject" -b bcc_user@some.com -c cc_user@some.com  -r sender@some.com recipient@example.com
mtk
  • 13,221
  • 16
  • 72
  • 112
9

In my case I have to keep multiple id's in cc which has been done by giving the email-id's comma separated one by one as below:

$ echo -e "Hi Team, \n \n Action Needed \n \n Regards, \n XYZ team"| mailx -s "subject" -b bcc_user1@some.com,bcc_user2@some.com -c cc_user1@some.com,cc_user2@some.com -r sender@some.com receiver@xyz.com

Also made use of the echo command to pass multiple lines to mailx utility. Thought it will be helpful.

budiDino
  • 13,044
  • 8
  • 95
  • 91