Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STARTTLS extension not supported by server

Tags:

python

email

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('[email protected]', 'abc123')
addressbook=sys.argv[1]
like image 232
XXX Avatar asked Jun 15 '11 09:06

XXX


1 Answers

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('[email protected]', 'abc123')
like image 76
Leonard Huang Avatar answered Sep 30 '22 20:09

Leonard Huang