English 中文(简体)
B. 不受服务器支持的扩展
原标题:STARTTLS extension not supported by server
  • 时间:2011-06-15 09:10:31
  •  标签:
  • python
  • email

这可能是一个反复出现的问题,但我仍面临这个问题,希望能找到解决办法。 提前感谢。

I m 试图通过公司服务器发送邮件

Im目前使用Aval版本2.6和Ubraham 10.04

这是我的错误信息。

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.

这里是法典的一部分。

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]
问题回答

Remove the ehlo() before starttls(.

starttls() + ehlo(>>>在两份HELLO电文中得出结果,使服务器在回复电文中删除

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

我还有一个类似问题,试图通过公司服务器发出邮件(不需要自发)。

我拆除了<条码>server.ehlo,删除了港口号:

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

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()

这些错误都说了,看来员工和管理当局协调会服务器库正在使用斜线支持《裁减战略武器条约》和你正在签发<编码>server.starttls()。 使用服务器时没有电话server.starttls()

没有更多的信息,我只能说。

我能够用以下代码来解决这个问题,用服务器名称增加港口号码:

server = smtplib.SMTP( smtp.abc.com:587 )
from smtplib import SMTP_SSL, SMTP, SMTPAuthenticationError
from ssl import create_default_context
from email.message import EmailMessage

sender =  aaa@bbb.com 
description = "This is the test description supposed to be in body of the email."
msg = EmailMessage()
msg.set_content(description)
msg[ Subject ] =  This is a test title 
msg[ From ] = f"Python SMTP <{sender}>"
msg[ To ] =  bbb@ccc.com 


def using_ssl():
    try:
        server = SMTP_SSL(host= smtp.gmail.com , port=465, context=create_default_context())
        server.login(sender, password)
        server.send_message(msg=msg)
        server.quit()
        server.close()
    except SMTPAuthenticationError:
        print( Login Failed )


def using_tls():
    try:
        server = SMTP(host= smtp.gmail.com , port=587)
        server.starttls(context=create_default_context())
        server.ehlo()
        server.login(sender, password)
        server.send_message(msg=msg)
        server.quit()
        server.close()
    except SMTPAuthenticationError:
        print( Login Failed )

通过测试和研究,我发现,电子邮件服务器不再使用与 p的联系。

不能使用服务。 电子邮件服务不再支持这种联系。

Also remember to use the SMTP ports (mail reserved ports) for sending emails. POP3 and IMAP ports for receiving email.


        s_u = "Test"

        service = smtplib.SMTP_SSL("smtp.gmail.com", 465)

        service.ehlo()

        service.sendmail("SENDER_EMAIL","RECEIVER_EMAIL","MESSAGE")

        

You can t send the email even if you put the correct credentials, look at this: Login credentials not working with Gmail SMTP

你们是否希望加密与邮件服务器的联系? 我会与那些知道该服务器内部的人联系,看看如何使用礼宾/加密。

你说,在取消对<编码>server.starttls()的号召时,你收到了不同系列的错误信息。 还请你公布这些讯息吗?

而且,你不妨读一下“起始”文件,以便你了解情况以及你为什么要使用它。 似乎你重写了严肃的商业方案,在这种情况下,你可能想要了解你正在做的事情,即安全。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签