STARTTLS extension not supported by server

自闭症网瘾萝莉.ら 提交于 2021-02-18 09:51:52

问题


This maybe a repeated question but I'm still facing issues on this, hope there's a solution around. Thanks in advance.

I'm trying to send mail through the company's server

I'm currently using Python version 2.6 and Ubuntu 10.04

This is the error message I got

Traceback (most recent call last):

  File "hxmass-mail-edit.py", line 227, in <module>
    server.starttls()

  File "/usr/lib/python2.6/smtplib.py", line 611, in starttls
    raise SMTPException("STARTTLS extension not supported by server.") smtplib.SMTPException: STARTTLS extension not supported by server.

Here goes part of the code

server = smtplib.SMTP('smtp.abc.com', 587)
server.set_debuglevel(1)
server.ehlo()
server.starttls()
server.ehlo()
server.login('sales@abc.com', 'abc123')
addressbook=sys.argv[1]

回答1:


Remove the ehlo() before starttls().

starttls() + ehlo() results in two HELLO messages, which cause the server remove the STARTTLS in the reply message.

server = smtplib.SMTP('smtp.abc.com', 587)
server.starttls()
server.ehlo()
server.login('sales@abc.com', 'abc123')



回答2:


I had a similar issue trying to send a mail through the company's server (without autentication needed)

I solved removing the server.ehlo and removing the port number:

server = smtplib.SMTP("smtp.mycompany.com")
server.sendmail(fromaddr, toaddr, text)



回答3:


removing server.ehlo() before server.starttls() helped me get my code working! Thank you, Leonard! my code:

s = smtplib.SMTP("smtp.gmail.com",587)
s.starttls()
s.ehlo
try:
    s.login(gmail_user, gmail_psw)
except SMTPAuthenticationError:
    print 'SMTPAuthenticationError'
s.sendmail(gmail_user, to, msg.as_string())
s.quit()



回答4:


The error says it all, it seems the SMTP server sou are using doesn't support STARTTLS and you aru issuing server.starttls(). Try using the server without calling server.starttls().

Without more info is the only I can say.




回答5:


I am able to resolve the issue with below code, by adding port number with server name:

server = smtplib.SMTP('smtp.abc.com:587')



回答6:


Are you sure that you want to encrypt (StartTLS) the connection to the mail server? I would contact someone who knows the insides of that server to see what protocol/encryption to use.

You say that upon removing the call to server.starttls(), you get a different series of error messages. Could you please post those messages as well?

Also, you might want to read up on StartTLS so you understand what it is and why you would want to use it. It seems you're writing a Serious Business program, in which case you'll probably want to understand what you are doing, security-wise.




回答7:


Yes putting server.starttls() above server.ehlo() solved this.



来源:https://stackoverflow.com/questions/6355456/starttls-extension-not-supported-by-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!