For sending Email to a list of receivers using python can done by using the given code. Here I am using Gmail SMTP service for this purpose (Create a separate account for this, cause it might be dangerous to use your primary email address as the Gmail might suspend you account in case of spamming).
There are 3 things required
1. Message written in text file. (sampleMessage.txt)
2. List of receivers in csv file. (listReceivers.csv)
3. Edit your Gmail account security to allow access for less secure apps by using the below link. https://www.google.com/settings/security/lesssecureapps
and select turn on.
Keep your sampleMessage.txt, listReceivers.csv and sendEmail.py file under the same directory.
Here is the code for sending the email to the receivers (sendEmail.py)
from email.mime.text import MIMEText
fp = open('sampleMessage.txt','rb')
msg = MIMEText(fp.read())
msg['Subject'] = 'Test Email'
msg['From'] = 'email@example.com' #put the email address of sender
server = smtplib.SMTP('smtp.gmail.com:587')
server.login(msg['From'],'xxxxxxxxxxx') #put sender's password here
email_data = csv.reader(open('listReceiver.csv','rb'))
email_pattern = re.compile("^.+@.+\..+$")
flag = 0
for row in email_data:
msg['To'] = row
print "Message sent to ", row
flag = 1
print "Error occoured while sending the emails"
if flag == 0:
print "Messages are sent sucessfully"
Output after running the program
Message sent to Abhishek
Message sent to Mukesh
Message sent to Ayush
Message sent to Pankaj
Messages are sent sucessfully