python 2.4中的服务器不支持SMTP AUTH扩展 [英] SMTP AUTH extension not supported by server in python 2.4
问题描述
这是我在VPS托管中提供python 2.4的正常代码
This is my normal code in my VPS hosting which provide python 2.4
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.
but unfortunately return this message! :
SMTP AUTH extension not supported by server.
在我安装了python 2.7的计算机上,我找到了解决方案,它的工作原理很好,这是此代码:
in my computer which i've install python 2.7 i found the solution and it's work very good here is this code :
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'
But in the VPS which installed python 2.4 doesn't have SMTP_SSL() and return this message 'module' object has no attribute 'SMTP_SSL'
我也尝试在VPS中升级python,但是发生的是损坏整个python,这意味着python根本无法工作.
Also i've tried to upgrade my python in VPS but what happened is Damage the whole python that mean python not work at all.
推荐答案
谢谢,我已经找到了解决方案,这就是解决方案=)
Guys thanks i've found the solution and this is the solution =)
def mail(receiver,Message):
import smtplib
try:
s=smtplib.SMTP()
s.connect("smtp.gmail.com",465)
s.ehlo()
s.starttls()
s.ehlo()
s.login("email@gmail.com", "password")
s.sendmail("email@gmail.com", receiver, Message)
except Exception,R:
return R
这篇关于python 2.4中的服务器不支持SMTP AUTH扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!