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
568 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 500 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

635 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