这是我在提供 python 2.4 的 VPS 主机中的正常代码
def mail(receiver,Message):
import smtplib
try:
s=smtplib.SMTP()
s.connect("smtp.gmail.com",465)
s.login("email@gmail.com", "password")
s.sendmail("email@gmail.com", receiver, Message)
except Exception,R:
return R
但不幸的是返回此消息!:
SMTP AUTH extension not supported by server.
在我安装了 python 2.7 的计算机中,我找到了解决方案,它的工作非常好这里是这段代码:
def mail(T,M):
import smtplib
try:
s=smtplib.SMTP_SSL()
s.connect("smtp.gmail.com",465)
s.login("xxxxx@gmail.com","your_password")
s.sendmail("xxxxx@gmail.com", T, M)
except Exception,R:
print R
但是在安装了 python 2.4 的 VPS 中没有 SMTP_SSL() 并返回此消息'module' object has no attribute 'SMTP_SSL'
我也尝试在 VPS 中升级我的 python,但发生的事情是损坏了整个 python,这意味着 python 根本不起作用。