Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2012-04-12
2
Medium Priority
?
569 Views
Last Modified: 2012-04-12
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.
0
Comment
Question by:labradorchik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 37838887
(echo "----------------------------------------------------------------"
      echo "Module10 Update Program"
      echo "ERR Msg: Module10 failed review program LOG"
      echo "----------------------------------------------------------------") | mailx -s $mailSubject $(cat $mymail)

My suggestion will also work if the file contains a single address per line.
0
 

Author Comment

by:labradorchik
ID: 37839199
Script works great!! Thank you!!! :)
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Utilizing an array to gracefully append to a list of EmailAddresses
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question