Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中发送但未接收电子邮件_Python_Email - Fatal编程技术网

在python中发送但未接收电子邮件

在python中发送但未接收电子邮件,python,email,Python,Email,我试过用python编写一个简单的电子邮件脚本来理解它的功能。代码是 import smtplib sender = 'avin@gmail.com' receivers = ['avin.b@vipointsolutions.net'] message = "This is a test e-mail message." try: smtpObj = smtplib.SMTP('localhost') smtpObj.sendmail(sender, receiv

我试过用python编写一个简单的电子邮件脚本来理解它的功能。代码是

import smtplib
sender = 'avin@gmail.com'
receivers = ['avin.b@vipointsolutions.net']
message = "This is a test e-mail message."

try:
smtpObj = smtplib.SMTP('localhost')    
smtpObj.sendmail(sender, receivers, message)
print("Successfully sent email")
except Exception:
print("error")

当我尝试运行此操作时,我收到消息
已成功发送电子邮件
,但电子邮件未发送到我的收件箱。我已在端口25的本地计算机上设置了postfix。有人能告诉我电子邮件未接收的原因吗?是因为代码吗?任何帮助都将不胜感激。

您必须提供电子邮件发件人的SMTP,并且必须从发件人电子邮件登录

例如:

sender = 'avin@gmail.com'
receivers = 'avin.b@vipointsolutions.net'
msg_format = "Hello, Test email"
server = smtplib.SMTP('smtp.office365.com')
            server.starttls()
            server.verify(receivers)
            server.login(sender, 'password')
            server.sendmail(sender, receivers, msg_format)
            server.quit()
print("Successfully sent email")

我使用smtp.google.com尝试过这段代码,也使用过我的gmail密码,但是当我运行代码时,它仍然处于运行状态,并且没有显示任何消息。gmail的MTP服务器地址是
smtp.gmail.com
try with this。@我尝试过,但问题仍然存在。程序没有显示任何错误。它只是处于进程状态,但是我最近的收件箱中没有收到电子邮件