【发布时间】:2020-08-07 13:43:35
【问题描述】:
我知道还有其他类似的问题,但我遵循了答案,但我的代码仍然有同样的错误:
import csv, smtplib, ssl
message = """Subject: Test
Hi {name}"""
from_address = "random@gmail.com"
password = "pasword"
context = ssl.create_default_context()
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
server.login(from_address, password)
with open("contacts_file.txt") as file:
reader = csv.reader(file)
next(reader)
next(reader)
for number, name, email in reader:
server.sendmail(
from_address, email, message.format(name=name)
)
server.quit()
谢谢!
【问题讨论】:
-
你用的是什么版本的python?
with支持在 3.3 中添加到 smtplib
标签: python ssl server smtp attributeerror