using mailx with multiple recipients


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers using mailx with multiple recipients
# 1  
Old 10-06-2006
using mailx with multiple recipients

I am trying to use a file containing email addresses in my mailx command like the following:

SUBJECT="Kronos User Report"
BODY="kronos.txt"
MAILTO="kronosmail.txt"
mailx -s "$SUBJECT" $MAILTO < $BODY

This works fine for the body of the message but for the recipient it says:

kronosmail.txt... User unknown

Right now I have a single email address in the knonosmail file but it will grow, that is why I am using the file instead of hardcoding it in the script. I have tried variations of quotation marks to no avail. Please advise.
# 2  
Old 10-06-2006
Change MAILTO="kronosmail.txt" to
MAILTO=`cat kronosmail.txt`

You man also need to put in where exactly this file is.
Example:
MAILTO=`cat /home/mydirectory/kronosmail.txt`
# 3  
Old 10-06-2006
Worked perfectly, thank you very much.
# 4  
Old 10-06-2006
Quote:
Originally Posted by RTM
Change MAILTO="kronosmail.txt" to
MAILTO=`cat kronosmail.txt`

You man also need to put in where exactly this file is.
Example:
MAILTO=`cat /home/mydirectory/kronosmail.txt`
Another UUOC?

MAILTO=$(< /home/mydirectory/kronosmail.txt)
# 5  
Old 10-06-2006
This syntax worked correctly also, thanks for the tips. Not exactly sure what 'Another UUOC?' refers to.
Nevermind, Google provided enlightenment.
# 6  
Old 08-17-2008
Question: Size of list

Ok. That works wonderfully.

How many email addresses can be in that list before it's too many for a single authentication to the mail server?

Does the mail server limit this number?
Does the mailx application limit it?
Is this method suitable for mass emailing a huge website's members list?

Just wondering.
# 7  
Old 08-18-2008
LINE_MAX bytes - usually something like 2048 is the maximum length of an input line to mailx. This includes the "to" line. Check this for your system.

However, mail servers limit line size, and spam blockers may also stop messages like that. Since mail requests are processed asynchronously some code like this works:

assume that mail.txt is a list of email addresses -
Code:
while read dest
do
  echo "this is a test" |  \
    mailx -s 'trying to have my IP shutdown my account as a spambot'  $dest
done < mail.txt

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Problem getting mailx to send true Bcc mail to multiple recipients

I am having trouble getting mailx to send multiple Bcc mails out without everyone in the list of recipients seeing everyone else's email addresses. I looked at the man pages of my system and seem to be following the syntax correctly, but the mails still go out as if I were just putting in a list of... (7 Replies)
Discussion started by: legrandtimonier
7 Replies

2. UNIX for Advanced & Expert Users

Sendmail not showing recipients

I've figured out to do a mail merge with /usr/lib/sendmail which is extremely helpful as it is lightning fast compared to an Outlook mail merge which pretty much locks up my machine while it struggles to push out the emails. I figured out how to send html emails, with dynamic variables, and how... (8 Replies)
Discussion started by: MaindotC
8 Replies

3. Shell Programming and Scripting

Sending Multiple Attachments using MAILX

I have created a shell scripts and wanted to email users multiple attachments using mailx. I noticed that when I do a man on mailx I see and -a option for attachments. When I run a: mailx -s "test attachments" -a include_file -a exclude_file testuser@mydomain.com (Interrupt -- one more to... (1 Reply)
Discussion started by: metallica1973
1 Replies

4. UNIX for Advanced & Expert Users

Multiple recipients with sendmail

Hi, I use the following to send a mail : sendmail -v someone@box.com < /appli/oracle/rap.txt Can I give several mail address for destination ? How ? For exemple : sendmail -v someone@box.com, someone2@box.com, someone3@box.com < /appli/oracle/rap.txt Thank you. (6 Replies)
Discussion started by: big123456
6 Replies

5. Shell Programming and Scripting

mailx problem with multiple cc

I am writing a script to send an email of the result of the process but i cannot make the cc work correctly. RECIP="abc@example.com def@example.com" CC="ghi@example.com jkl@eaxmple.com" mailx -s "testing" -c $CC $RECIP < inputfile.txt Result: To: abc@example.com; def@example.com;... (4 Replies)
Discussion started by: The One
4 Replies

6. Shell Programming and Scripting

mailx script to do multiple emails

I am looking for a script that I can use with mailx to do the following: 1. Grab usernames from a flat file (one at a time) 2. Attach a file to the email and mail out. Thanks. Cubefeed (3 Replies)
Discussion started by: CubeFeed
3 Replies

7. Shell Programming and Scripting

Not able to send multiple attachments using uuencode and mailx

Hi, I am seeing some junk characters when I attach the second file, given below is the logic I used. Please help me resolving the issue. ( uuencode file1.txt file1.txt.lst && uuencode file2.txt file2.txt.lst ) > attachment.txt cat body.txt attachment.txt > combinemail.txt mailx -m... (7 Replies)
Discussion started by: prasperl
7 Replies

8. Programming

Python: multiple email recipients

I am using a the following backup script to backup a server to USB. USBBackupScript - RdiffBackupWiki However I don't know python and would like to alter the script so I can send emails about the success or failure of the backup to multiple recipients. I did do some research but the limit... (0 Replies)
Discussion started by: jelloir
0 Replies

9. Shell Programming and Scripting

uuencode mailx - send multiple emails

The following is an extract from one of my Shell Scripts which uses uuencode and mailx to send an email with multiple attachements: uuencode $LOG_REPORT $(basename $LOG_REPORT) uuencode $HTML_FILE $(basename $HTML_FILE ) ) | if then mailx -b "$COPY_TO" -s "$SUBJECT" -r "$MAIL_FROM"... (2 Replies)
Discussion started by: suthera
2 Replies

10. UNIX for Dummies Questions & Answers

Multiple File Attachment Using Mailx

HI, I want to send mail using mailx and also want to attach all files under specific directory.(*.*). Please show me a script. Thanks (3 Replies)
Discussion started by: pnathani
3 Replies
Login or Register to Ask a Question