Link to home
Start Free TrialLog in
Avatar of labradorchik
labradorchikFlag for United States of America

asked on

How to include email addresses within a file and then send a message by using that file in the Unix bash shell script?

In the Unix bash script, how can I create a file with some email addresses and then use that file to send messages through Unix bash shell script?

For example, I would like to send my message to: person1@yahoo.com, person2@yahoo.com, and person3@yahoo.com  

How above email addresses need to be entered in the file "mailfile.txt" and what would be a command to send "mailfile.txt" in the Unix bash shell script?

I tied to enter email addresses in the "mailfile.txt" the following way:
person1@yahoo.com, person2@yahoo.com, person3@yahoo.com

then I tried to run below sript:

mailSubject="ERROR: Module10 - FAILED, REVIEW Program LOG"
mydir=/year/month/week/day
mymail=$mydir/mailfile.txt

     (echo "----------------------------------------------------------------"
      echo "Module10 Update Program"
      echo "ERR Msg: Module10 failed review program LOG"
      echo "----------------------------------------------------------------") | mailx -s $mailSubject $mymail

Open in new window

No errors are produced and no mail has been send to those three recipients.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of labradorchik

ASKER

Script works great!! Thank you!!! :)