LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  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

bob:marley:bob.marley@gmail.com
nikki:minaj:nikkithedash@gmail.com
sachin:tendulkar:sachin.india@gmail.com

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
bob.marley@gmail.com
nikkithedash@gmail.com
sachin.india@gmail.com


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
Thanks
 
Old 07-03-2015, 02:24 AM   #2
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Xubuntu, Manjaro
Posts: 745
Blog Entries: 3

Rep: Reputation: 347Reputation: 347Reputation: 347Reputation: 347
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,
HMW
 
Old 07-03-2015, 06:15 AM   #3
eklavya
Member
 
Registered: Mar 2013
Posts: 619

Rep: Reputation: 136Reputation: 136
Are body and subject of all mails same? if yes, you can write a shell script for it like
Code:
#!/bin/bash
IFS=$'\n'
ARRAY14=( $(cat emails) )
for i in "${ARRAY14[@]}" 
do 
echo "Mail Body" | mail -s "Mail Subject" "$i"
echo "Sent mail to $i"
done
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.
 
  


Reply


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


All times are GMT -5. The time now is 01:06 AM.

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