我正在尝试使用yagmail通过代码发送电子邮件,但是出现错误
YagInvalidEmailAddress: Emailaddress "Gmail" is not valid according to RFC 2822 standards
我的代码如下。
import yagmail
sender_email = '*********'
sender_password = '*******'
df = pd.read_csv("file.csv")
first_msg="""
if true send this
"""
second_msg="""
if false send this
"""
df1= df['Name'][df[new_col] == 'True']
print("True")
msg= first_msg.format("Name")
df1= df['Name'][df[new_col] == 'False']
print("False")
msg= second_msg.format("Name")
receiver_email = ("{}".format("Gmail"))
subject = 'test'
yag = yagmail.SMTP(user=sender_email, password=sender_password)
contents = msg
yag.send(to=receiver_email, subject=subject,contents=contents)
csv文件的内容很简单
Name Gmail
mark ***@gmail.com
trish ***@gmail.com