Send a mail to IDs listed in a text file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Send a mail to IDs listed in a text file
# 1  
Old 03-11-2010
Send a mail to IDs listed in a text file

I have a list of mail ids in text file and want a ksh script that reads this text file and sends a mail to all mail ids with same subject line and content.

I am using UX-HP machine and KSH.

Thanks for help in advance!
# 2  
Old 03-11-2010
what is the format of the text file?
are the Ids on each line? csv?
# 3  
Old 03-11-2010
txt file can be anything, I just have a list of mail IDs. not sure what format of file to put these mail IDs. but list may grow in future. so, option should be there to add mail IDs later to the file.
# 4  
Old 03-11-2010
from the format i was trying to ask that you file contains the IDs like,


Code:
abc.123@domain.com,abc.123@domain.com,abc.123@domain.com

or

abc.123@domain.com
abc.123@domain.com
abc.123@domain.com

or 

abc.123@domain.com|abc.123@domain.com|abc.123@domain.com

or even simply,

abc.123@domain.com abc.123@domain.com abc.123@domain.com



try respectively,
Code:
 
echo 'this is content' | mailx -s 'subject' $(cat file | tr ',' ' ')
or
echo 'this is content' | mailx -s 'subject' $(cat file | tr '\n' ' ')
or
echo 'this is content' | mailx -s 'subject' $(cat file | tr '|' ' ')
or
echo 'this is content' | mailx -s 'subject' $(cat file)


Last edited by clx; 03-11-2010 at 05:32 AM.. Reason: added solution
# 5  
Old 03-11-2010
I have a text file mail_list.txt where mail ids are list one below the other
Ex:

abbc@xyz.com
zxcv@xyz.com
sdfg@xyz.com
# 6  
Old 03-11-2010
Code:
#!/bin/ksh
sendm()
{
sendto="$1"
/usr/lib/sendmail -t -i <<EOF
Subject: some
From: some
To: $sendto

Maildata

EOF
}

##### main #####
cat somefile | while read addr
do
      sendm "$addr"
done

More sendmail examples.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Manipulate condition to send mail based on output text in file

Hi All, I have a working script as below. echo "Files loaded with $(cat /var/tmp/script.X1.out)" | mail -s "Files loaded with return code" mailid This script takes the output from script.X1.out file and appends the text "Files loaded with return code" and sends the email. Now what I want... (5 Replies)
Discussion started by: midhun3108
5 Replies

2. Shell Programming and Scripting

Want to delete the junk files from a directory which are not listed in a TEXT file

Hello Everyone, I want to delete the image files from a directory, which are not listed in a TEXT file. The directory contains large number of image files (in millions) required / not required. I want to delete the image files which are "not required". I have generated a Text file having... (3 Replies)
Discussion started by: Praveen Pandit
3 Replies

3. Shell Programming and Scripting

Delete files listed in text file

Hi Team, Here's the scenario, I have a text file called "file_list.txt". Its content is as follows. 111.tmp 112.tmp 113.tmp 114.tmp These files will present in "workdir" directory. It has many files. But only the files present in file_list.txt has to be deleted from the workdir... (7 Replies)
Discussion started by: kmanivan82
7 Replies

4. Shell Programming and Scripting

How to grep a log file for words listed in separate text file?

Hello, I want to grep a log ("server.log") for words in a separate file ("white-list.txt") and generate a separate log file containing each line that uses a word from the "white-list.txt" file. Putting that in bullet points: Search through "server.log" for lines that contain any word... (15 Replies)
Discussion started by: nbsparks
15 Replies

5. Shell Programming and Scripting

Copy files listed in text file to new directory

I am trying to write a script that will copy all file listed in a text file (100s of file names) to a new directory Assume script will run with main as current working directory and I know how many files/lines will be in List.txt Im trying to work up a test script using this model Contents of... (2 Replies)
Discussion started by: IAmTheGrass
2 Replies

6. Shell Programming and Scripting

send text mail to windows

Hi I have the following 'atd' batch script to send mail to a windows (outlook) system: .... .... LESSOPEN=\|/usr/bin/lesspipe.sh\ %s; export LESSOPEN G_BROKEN_FILENAMES=1; export G_BROKEN_FILENAMES cd /root/bin || { echo 'Execution directory inaccessible' >&2 exit 1 }... (3 Replies)
Discussion started by: AdminLew
3 Replies

7. Shell Programming and Scripting

Shellscript to sort duplicate files listed in a text file

I have many pdf's scattered across 4 machines. There is 1 location where I have other Pdf's maintained. But the issues it the 4 machines may have duplicate pdf's among themselves, but I want just 1 copy of each so that they can be transfered to that 1 location. What I have thought is: 1) I have... (11 Replies)
Discussion started by: deaddevil
11 Replies

8. Shell Programming and Scripting

Copy files listed in a text file - whitespace problem.

Hi, Say I have this text file <copy.out> that contains a list of files/directories to be copied out to a different location. $ more copy.out dir1/file1 dir1/file2 dir1/file3 "dir1/white space" dir1/file4 If I do the following: $copy=`more copy.out` $echo $copy dir1/file1... (4 Replies)
Discussion started by: 60doses
4 Replies

9. UNIX for Advanced & Expert Users

Script which can send file to diffrent mail ids.

Hi i am looking for the script which can send file to different mailids, please halp me out. Thanks in advance. (3 Replies)
Discussion started by: vpandey
3 Replies

10. UNIX for Dummies Questions & Answers

Send text file to mail

I have a utility that opens a telnet session and allows me to execute commands through a script. The utility allows me to output to a text file whatever is outputted to screen. This utility runs from a DOS prompt in Windows 95/98, NT or 2000. How can I mail text file this to a certain user. I... (2 Replies)
Discussion started by: petrosi
2 Replies
Login or Register to Ask a Question