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

How do you invoke and send mail from unix ?

Asked by: anandvoona | Member Since Jun-2008 | Asked on: Jun 10th, 2011

View all questions by anandvoona

Showing Answers 1 - 3 of 3 Answers
Shyam

Answered On : Jul 24th, 2011

This is how you can do mailx from the unix prompt.
Go to the path where the source file resides.
pwd> uuencode | mailx

usually in big corporations your network id is mapped to your email address.

  
Login to rate this answer.

The following is a more detailed example for using mailx in shell script. This should help.

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!!"
  24.  

  
Login to rate this answer.
Mohankumar

Answered On : Feb 14th, 2012

Code
  1. mailx -s "<subject>" <email_id list> < <input_file>

  
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.