Hey i want to send an email to a bunch of people but for some reason even if the output of print is more than one email the program sending the email only to first person of the text what can i do ?
# Import Python Packages
import smtplib
# Set Global Variables
gmail_user = 'your@gmail.com'
gmail_password = 'password'
# Create Email
mail_from = gmail_user
for i in range(2):
with open('C:\\email.txt', 'r', encoding="utf8") as f
mail_to = f.read().rstrip()
mail_subject = 'subject'
mail_message_body = 'body'
mail_message = '''\
From: %s
To: %s
Subject: %s
%s
''' % (mail_from, mail_to, mail_subject, mail_message_body)
# Sent Email
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login(gmail_user, gmail_password)
server.sendmail(mail_from, mail_to, mail_message)
print(mail_to)
server.close()