Aug-17-2018, 06:26 PM
import re import smtplib from email.mime.text import MIMEText import cvs fp = open('message.txt', 'rb') msg = MIMEText(fp.read()) fp.close() msg['Subject'] = 'Subject goes here' msg['From'] = '[email protected]' server = smtplib.SMTP('smtp.gmail.com:587') server.starttls() server.login('[email protected]', 'password') email_data = csv.reader(open('email.csv', 'rb')) email_pattern= re.compile("^.+@.+\..+$") for row in email_data: if( email_pattern.search(row[1]) ? del msg['To'] msg['To'] = row[1] try: server.sendmail('[email protected]', [row[1]], msg.as_string()) except SMTPException: print "An error occured." server.quit()I just did some amendment in this code and it is working but could you tell me how I set interval between each email sent because I don't want to send it once instead want to keep interval of 5 to 10 min in each email.
PS: If you could set email rotation then I would highly appreciate. Email rotation means suppose; I have one email format " Email format " and want to send it via email a , b,c ,d i mean just want a rotation first email sent by [email protected] then [email protected] again [email protected] .... then again a@gmail i mean like rotation of email id so that i can send more email with different email ids in same time.