My code takes the txt file and sends an email to the first email in the list and then stops and doesn't do it for the next. What am I doing wrong with this array?
I have tried creating an array to run the function for each email in target_email
and it only sends an email to the first email in the array. When I print the array it looks like this [123@txt.att.net, 876@txt.att.net]
####the py script
import time
import smtplib
#CONFIG. You can change any of the values on the right.
email_provider = '' #server for your email- see ReadMe on github
email_address = "" #your email
email_port = 587 #port for email server- see ReadMe on github
password = "" #your email password
msg = "Meow" #your txt message
text_amount = 1 #amount sent
#Gets phone number emails from txt file
text_file = open("mails.txt", "r")
target_email = text_file.readlines()
wait = 15 #seconds in between messages
#END CONFIG
#Loops for each phone email in list text_amount of times
for emails in target_email:
server = smtplib.SMTP(email_provider, email_port)
server.starttls()
server.login(email_address, password)
for _ in range(0,text_amount):
server.sendmail(email_address,target_email,msg)
print("sent")
time.sleep(wait)
print("{} texts were sent.".format(text_amount))
###the txt file contents
123@txt.att.net, 876@txt.att.net
The script should run the ### DO NOT EDIT BELOW THIS LINE ###
for each email individually and not a BBC or just send to one email and stop.