How do you invoke and send mail from unix ?

Questions by anandvoona

Showing Answers 1 - 19 of 19 Answers

Shyam

  • 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.

  Was this answer useful?  Yes

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.  


  Was this answer useful?  Yes

Mohankumar

  • Feb 14th, 2012
 

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

  Was this answer useful?  Yes

Mohit

  • Nov 17th, 2014
 

to print file as message
cat filename|mailx -s "subject" mail_id
to attach file
uuencode file_name file_name|mailx -s "subject" mail_id

  Was this answer useful?  Yes

Sanjeev

  • Apr 3rd, 2015
 

mailx -S "" << HERE
mail body
HERE
# I have used HERE document concept

  Was this answer useful?  Yes

vishnu

  • Aug 1st, 2017
 

using mutt, mailx, or uuencode

  Was this answer useful?  Yes

Shrey Shekhar

  • Sep 5th, 2020
 

cat file_name|uuencode file_name|mail -s subject line reciepent_email_address

  Was this answer useful?  Yes

Give your answer:

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

 

Related Answered Questions

 

Related Open Questions