简体   繁体   English

尽管包含不存在的电子邮件,Python sendmail() 仍返回 {}

[英]Python sendmail() returns {} despite including emails that don't exist

I was experimenting sending emails using python and smtplib .我正在尝试使用 python 和smtplib发送电子邮件。 I am aware that if the email was sent to all email addresses then sendmail() returns {}.我知道如果电子邮件已发送到所有电子邮件地址,则sendmail()返回 {}。 But I intentionally added 2 email addresses (bbbbbbbbbb@gmail.com and ccccccccccccc@gmail.com) that do not exist (I confirmed they don't exist by checking sent items in my gmail account) and still got an empty dictionary.但是我故意添加了 2 个不存在的电子邮件地址(bbbbbbbbbb@gmail.com 和 ccccccccccccc@gmail.com)(我通过检查我的 gmail 帐户中的已发送邮件确认它们不存在)并且仍然得到一个空字典。 Is something going wrong here?这里有什么问题吗?

import smtplib

smtpobj=smtplib.SMTP('smtp.gmail.com',587) #creating an SMTP object. 
smtpobj.ehlo() #saying hello to the server

smtpobj.starttls() #enabling encryption for the connection

password=str(input("Please enter your password: "))

smtpobj.login('thereallasad@gmail.com', password) #logging in to account

lst=['govindsomadas@gmail.com', 'thereallasad@gmail.com', 'bbbbbbbbbbbbbbbbbb@gmail.com','ccccccccccccccccc@gmail.com']

smtpobj.sendmail('thereallasad@gmail.com', lst, 'Subject: Testing\nDear Govind,\n\nThanks for creating me.\n\nRegards,\nLasad')

print(smtpobj.sendmail('thereallasad@gmail.com', lst, 'Subject: Testing\nDear Govind,\n\nThanks for creating me.\n\nRegards,\nLasad'))

smtpobj.quit() #disconnects from smtp server

It will return an empty dictionary if even one of the email addresses worked, if none works then it raises an exception.如果其中一个电子邮件地址有效,它将返回一个空字典,如果没有,则引发异常。 Try sending an email to all the wrong emails.尝试向所有错误的电子邮件发送电子邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM