GeekInterview.com
Series: Subject: Topic:
Question: 5 of 55

Syntax for mailx command

Hello,
I am trying to write a unix shell script program to send mail to cc and to list.I am using the '-c' option for mailx unix command,but am getting an error illegal -c option.
Could any one please guide me to use the mailx command in unix shell scripting to send the mail to the Cc and To list along with the attachment ?

Thanks in advance
Appreciate the response
Asked by: shalinik.sdm | Member Since Nov-2009 | Asked on: Jun 20th, 2011

View all questions by shalinik.sdm

Showing Answers 1 - 2 of 2 Answers

You should be able to use something like the following example to get the CC option working with mailx. Preferably create a list of users needed to be put in the CC option (as mailCClist.txt in the example). Hope this helps.

Code
  1. SUBJECT="Email Subject Line"
  2. TO=xyz@company.com
  3. CC=`tr '
  4. ' ', ' < mailCClist.txt`
  5. #BCC="xyz2@comp.com"
  6.  
  7. echo "Send the E-mail message..."
  8. /usr/bin/mailx -s "${SUBJECT}" ${TO} <<-END
  9.  
  10. ~< ! uuencode $DCdir/$FileName "Result.txt"
  11.  
  12. ~c ${CC}
  13. ~b ${BCC}
  14.         Hi,
  15.  
  16.         Blah, Blah.. body of the email.
  17.  
  18.         Thanks
  19.         Satya
  20.         ~.
  21.         END
  22.  
  23. echo "Mail Sent!!"

  
Login to rate this answer.
Mitra

Answered On : Nov 24th, 2011

Code
  1. uuencode attachment1 attachment1 | mailx -c x@yz.com,a@bc.com -s "subject" m@no.com

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.