因此,我需要通过工作发送大量电子邮件,并认为我会制作一个快速的python脚本来帮助我。它似乎以前曾经起作用,但现在不再起作用。
我仍然可以发送电子邮件,因此不会被列入黑名单。香港专业教育学院试图将收件人/发件人更改为无效。
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import csv
email_user = 'ronchik4444@gmail.com'
email_pass = input("Pasword:... ")
email_recip = 'ronb@mrkt365.com'
subject = "Hey, let's test?"
#creates a new multipart object and fills parameters
msg = MIMEMultipart()
msg['From'] = email_user
msg['To'] = email_recip
msg['subject'] = subject
#defines the message
body = "READ"
#attaches body to email
msg.attach(MIMEText(body, 'plain'))
#converts email object above to plain text format
text = msg.as_string()
#initizling server ('gmail smtp server', port# )
server = smtplib.SMTP('smtp.gmail.com',587)
#initizlizez a secure connection
server.starttls()
# logs in ('email', 'password')
server.login(email_user, email_pass)
with open ("contacts_file.csv") as file:
reader = csv.DictReader(file)
next(reader)
for row in reader:
Server.sendmail(email_user,email_recip,text)
print ('done')
#closes connection
server.quit()
没有错误消息,当我检查收件人收件箱时没有电子邮件。