Sending mail to multiple recipient added in a text file

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Sending mail to multiple recipient added in a text file
# 1  
Sending mail to multiple recipient added in a text file

I am trying to find a code that can help me mail to a list of recipients which are in a text file.

Sample code
$cat recipient.txt

I want a mailx step that can read contents of recipient.txt and mail to all the users.

I don't want to use mails coded as a part of script. mails should be in text file

function SendEmail {

  xsub="Some Subject Of Your Choosing."
  mail -s "$xsub" $xemails < $1

}  ## End-of-function SendEmail

Last edited by rbatte1; 02-25-2015 at 07:44 AM.. Reason: Removed auto-EMAIL tags. Added CODE tags and corrected spellings/case
# 2  
dest=$(cat email_names.txt | tr -s '\n' ' ' )
mailx -s "$xsub" $dest

Note the email addresses should NOT be comma-delimited. mailx is front end for sendmail.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #90
Difficulty: Easy
If you open vi specify a path to a file that does not exist, vi will create a new, blank file at that location in the filesystem and open it.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mail sending with multiple attachement(pdf and csv) with html content from Linux

Hi, We have a requirement to send multiple attachment(pdf and csv) along with html content in a single mail. For that we are using uuencode. It is working for single pdf attachment and html content. But we are unable to send both pdf and csv attachment with html content. Below is the script.... (5 Replies)
Discussion started by: dholea
5 Replies

2. Shell Programming and Scripting

sending multiple files along with mail message using uuencode

Hi, I have a requirement to send a mail with multiple files attached to it and along with the text message in the mail. I am trying sumthing like below but it only sends me the text message and no files attached to the mail. ---------------------------------------- ( uuencode file1... (1 Reply)
Discussion started by: sachinkl
1 Replies

3. Shell Programming and Scripting

Echo - Sending mail to multiple addresses

Hi, If I want my script to send a mail to multiple recipients I can do the following: if then echo $err_string1 | mailx -s "UAT CPU ALERT" echo $err_string1 | mailx -s "UAT CPU ALERT" fi Can this also be done something like: ... (1 Reply)
Discussion started by: runnerpaul
1 Replies

4. Shell Programming and Scripting

mailx -s not sending the file to mail address

Hi All, OS:Red Hat Linux 4 86x64 Below is my shell script which is not sending mail to the mail recipient: #!/bin/bash export MAILLIST="" cd <path_to_the_script_perf_report.sql> sqlplus / as sysdba @perf_report.sql if then cat <path_to_the_script/*MONTHLY*REPORT*.lst... (6 Replies)
Discussion started by: a1_win
6 Replies

5. Shell Programming and Scripting

Not able to attach text in body of email while sending mail with attachment

Hi, We have been trying to send mail with attachment and it is going fine, but when we try to attach a text to the body of the email, we find that the mail is going fine with the body text but the attachment is not going through. We are using ksh. The command that is successfull without the... (6 Replies)
Discussion started by: jmathew99
6 Replies

6. Shell Programming and Scripting

I want Trailer to be added into the text file.

Hi folks, I want Trailer to be added into the txt file the format is below. flatfile-> abc.txt count of the file is 500 records. I want the trailer in this format: TRAILER|500 (pipe delimeter). Please suggest the comands ASAP. Rgds Ann (5 Replies)
Discussion started by: Haque123
5 Replies

7. Shell Programming and Scripting

Get the latest added part of a text file?

Hi, I want to get the latest added part of a text file sent over the network to for analysis. Is there a tool to use to keep track of which part of a text file that has already been analysed so only the "new" lines will be sent and handled? I have checked a few tools but I still donīt know how to... (3 Replies)
Discussion started by: pcrs
3 Replies

8. UNIX for Dummies Questions & Answers

Sending mail in the dead.letter file

Sorry for this one ladies and gents, it's probably very easy but I don't know how to, sound familiar :-) I'm using sendmail on a web server that sends some mail through forms, not many. I've got sendmail configured to use our networks relay host and everything was working well. The power... (4 Replies)
Discussion started by: mjdavies
4 Replies

9. UNIX for Advanced & Expert Users

sending mails with attachment and also some text in mail body

Hi, Can some one help me with the syntax of the mailx that should send an attachment and also some text in the message body together. When I am using the following syntax it is not sending the attachment but only the message body. unix2dos -ascii $REPORTFILE | uuencode $PCFILE | mailx -s... (7 Replies)
Discussion started by: guptan
7 Replies

10. Shell Programming and Scripting

Need to attach a txt file while sending mail

Hi, I need to attach a txt file while sending mail thru Unix. Please help me out in this.. -Charan. (9 Replies)
Discussion started by: charan81
9 Replies

Featured Tech Videos