I am trying to make a mass texting application. The information for each person is stored in a mysql database (i.e. %phonenumber%@text.att.net). The idea is to get all the emails as a list and input it into this script. I’m not sure if I’m going about this right.
import sys
from smtplib import SMTP
def sendmail(toaddy, msg): #toaddy is a list!!!!
debuglevel = 0
smtp = SMTP()
smtp.set_debuglevel(debuglevel)
smtp.connect('YOUR.MAIL.SERVER', 26)
smtp.login('USERNAME@DOMAIN', 'PASSWORD')
fromaddy = USERNAME@DOMAIN
for user in toaddy
smtp.sendmail(fromaddy, user, msg)
smtp.quit()
You shouldn’t quit the smtp session after the first loop. Also, instead of looping over the list of addresses, the docs indicate that
sendmailaccepts a list: