Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-11-2010
Registered User
 

Join Date: Jul 2009
Location: Bangalore
Posts: 44
Thanks: 6
Thanked 0 Times in 0 Posts
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!
Sponsored Links
    #2  
Old 03-11-2010
Registered User
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 1,203
Thanks: 56
Thanked 98 Times in 96 Posts
what is the format of the text file?
are the Ids on each line? csv?
Sponsored Links
    #3  
Old 03-11-2010
Registered User
 

Join Date: Jul 2009
Location: Bangalore
Posts: 44
Thanks: 6
Thanked 0 Times in 0 Posts
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
Registered User
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 1,203
Thanks: 56
Thanked 98 Times in 96 Posts
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 anchal_khare; 03-11-2010 at 04:32 AM.. Reason: added solution
Sponsored Links
    #5  
Old 03-11-2010
Registered User
 

Join Date: Jul 2009
Location: Bangalore
Posts: 44
Thanks: 6
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #6  
Old 03-11-2010
kshji's Avatar
Registered User
 

Join Date: Jun 2009
Location: Finland
Posts: 499
Thanks: 0
Thanked 36 Times in 36 Posts

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.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Send mail with rich text / HTML with image rythym05 Shell Programming and Scripting 2 12-20-2009 01:52 PM
Shellscript to sort duplicate files listed in a text file deaddevil Shell Programming and Scripting 11 11-02-2009 04:54 AM
Copy files listed in a text file - whitespace problem. 60doses Shell Programming and Scripting 4 10-20-2008 07:14 PM
Send an attachment and html text both in the same mail stefan.yu Shell Programming and Scripting 4 10-26-2006 09:46 PM
Send text file to mail petrosi UNIX for Dummies Questions & Answers 2 02-20-2001 09:56 PM



All times are GMT -4. The time now is 03:33 AM.