I'm having difficulty getting python 2.4 to connect to gmail's smtp server. My below script doesn't ever get past "connection". I realise there is an SMTP_SSL class in later versions of python and it seems to work fine, but the production environment I have to deal with only has - and likely will only ever have - python 2.4.
我很难让python 2.4连接到gmail的smtp服务器。我的下面的脚本永远不会超过“连接”。我意识到在python的更高版本中有一个SMTP_SSL类,它似乎工作正常,但我必须处理的生产环境只有 - 而且很可能只有 - python 2.4。
print "connecting"
server = smtplib.SMTP("smtp.gmail.com", 465)
print "ehlo"
server.ehlo()
print "start tls"
server.starttls()
print "ehlo"
server.ehlo()
print "log in"
if self.smtpuser:
server.login(smtpuser, smtppassword)
Does anybody have any advice for getting the above code to work with python 2.4?
有没有人有任何建议让上面的代码与python 2.4一起使用?
3 个解决方案
#1
When I tried setting something similar up for Django apps, I could never get it to work on port 465. Using port 587, which is the other port listed in the GMail docs seemed to work.
当我尝试为Django应用程序设置类似的东西时,我永远无法在端口465上工作。使用端口587,这是GMail文档中列出的另一个端口似乎工作。
#2
Yes I used 587 as the port for my vb.net app too. 465 did not work for me too.
是的我也使用587作为我的vb.net应用程序的端口。 465也不适合我。
#3
try
server.ehlo('user.name@gmail.com')
in both places above
在上面的两个地方
also look at setting
也看看设置
server.set_debuglevel(1) value as required for more info
server.set_debuglevel(1)更多信息所需的值
#1
When I tried setting something similar up for Django apps, I could never get it to work on port 465. Using port 587, which is the other port listed in the GMail docs seemed to work.
当我尝试为Django应用程序设置类似的东西时,我永远无法在端口465上工作。使用端口587,这是GMail文档中列出的另一个端口似乎工作。
#2
Yes I used 587 as the port for my vb.net app too. 465 did not work for me too.
是的我也使用587作为我的vb.net应用程序的端口。 465也不适合我。
#3
try
server.ehlo('user.name@gmail.com')
in both places above
在上面的两个地方
also look at setting
也看看设置
server.set_debuglevel(1) value as required for more info
server.set_debuglevel(1)更多信息所需的值