【问题标题】:send SMTP email for office365 with python using tls/ssl使用 tls/ssl 使用 python 为 office365 发送 SMTP 电子邮件
【发布时间】:2019-07-06 22:29:04
【问题描述】:

我正在尝试创建一个 python 脚本来发送带有一些消息的电子邮件。 我的设置基于 smtp.office365.com。我创建了一些脚本来完成这项工作。

#!/usr/bin/python

print ("HI! let's start")  
import smtplib  
import getpass

port=587                                                                                                                    
smtp_server="smtp.office365.com"  
sender_email='mymail@something.com'  
receiver_email='mymail@something.com'  
print ("defining server")  
server = smtplib.SMTP(smtp_server,port)

password=getpass.getpass("enter password")

message='''
Hi,
THIS IS A TEST MESSAGE.
'''

print ("logging in")  
server.login(sender_email,password)  
print ("sending mail now")  
server_sendmail(sender_email,receiver_email,message)  
print ("all must be done by now")

但由于某些原因,打印“定义服务器”后卡住了。并且永远不会要求输入密码。显然 smtplib.SMTP 命令挂起。你能说出为什么会发生这种情况以及如何摆脱它吗?我的设置如下:

Server: smtp.office365.com
/sjmail.com
security : STARTTLS
Port : 587

【问题讨论】:

标签: python-2.7 smtp smtplib


【解决方案1】:

维谢什艾莉亚!

Office 365 帐户不支持 SMTP AUTH 扩展。搜索 Microsoft Graph 以执行此操作。

【讨论】:

    猜你喜欢
    • 2018-02-20
    • 2017-10-12
    • 1970-01-01
    • 1970-01-01
    • 2011-11-29
    • 2019-05-29
    • 2017-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多