Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-02-2015, 04:46 PM   #1
vamshi krishna
LQ Newbie
Registered: Jul 2015
Posts: 3

Rep: Reputation: Disabled
Post how to send email to multiple users which are grep'ed from a text file

I have a database of users called employees in the format of firstname:lastname:email

I grep'ed these values into a text file called email using
cat employees | cut -d":" -f4 > emails

Now the file has all the email ids in the file emails
cat emails

Now if I have a relatively bigger database of 1000 users and I have 1000 email ids in the emails file. How can i send emails to 1000 users at the same time??
Please help
Old 07-03-2015, 02:24 AM   #2
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 770
Blog Entries: 3

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
Short answer: You probably CAN'T send 1000 e-mails at the same time, because most ISP's have limits on their outgoing connections to avoid SPAM and such.

Long answer: If it were me, I would use Python and smtplib, read all e-mails into a list, loop the list and send each e-mail with a PAUSE (for say 7 seconds) after each mail has been sent.

There might be other ways, but that's how I would do it from the command line.

If you have access to a GUI, I suggest Thunderbird in combination with Mail Merge.

Best regards,
Old 07-03-2015, 06:15 AM   #3
Registered: Mar 2013
Posts: 622

Rep: Reputation: 136Reputation: 136
Are body and subject of all mails same? if yes, you can write a shell script for it like
ARRAY14=( $(cat emails) )
for i in "${ARRAY14[@]}" 
echo "Mail Body" | mail -s "Mail Subject" "$i"
echo "Sent mail to $i"
You can write Mail body and mail subject. You can use two more variables as body and subject and write detail content.
You can use "read" command to use different body and different subject for each recipient.
You can enter body and subject from a text file. You can use multiple text files to choose different body and different subject for different recipients.

There may be multiple options to send mail, you need to understand your requirement and how do you want to utilize resources.

Last edited by eklavya; 07-03-2015 at 06:17 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Read a file, and send an email to the users inside the file karthikbhuvanagiri Programming 7 03-19-2013 07:01 PM
grep a text in files and print the file name who don't contain such text whossa Linux - Newbie 5 04-13-2012 08:49 AM
Combine multiple one column text file into one text file with multiple colum khairilthegreat Linux - Newbie 7 11-23-2007 02:31 PM
automatically send an email to new users....? oru Slackware 2 09-14-2007 03:56 AM
How to allow selected users to send a email to a particular IP xanthium Linux - Networking 2 11-05-2002 09:49 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:45 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration