<small id='LkmGd'></small><noframes id='LkmGd'>

        <bdo id='LkmGd'></bdo><ul id='LkmGd'></ul>
    1. <legend id='LkmGd'><style id='LkmGd'><dir id='LkmGd'><q id='LkmGd'></q></dir></style></legend>

      <tfoot id='LkmGd'></tfoot>
      1. <i id='LkmGd'><tr id='LkmGd'><dt id='LkmGd'><q id='LkmGd'><span id='LkmGd'><b id='LkmGd'><form id='LkmGd'><ins id='LkmGd'></ins><ul id='LkmGd'></ul><sub id='LkmGd'></sub></form><legend id='LkmGd'></legend><bdo id='LkmGd'><pre id='LkmGd'><center id='LkmGd'></center></pre></bdo></b><th id='LkmGd'></th></span></q></dt></tr></i><div id='LkmGd'><tfoot id='LkmGd'></tfoot><dl id='LkmGd'><fieldset id='LkmGd'></fieldset></dl></div>

        Python 的 SMTP AUTH 扩展问题

        时间:2023-07-03
      2. <tfoot id='9KCYp'></tfoot>

        <small id='9KCYp'></small><noframes id='9KCYp'>

          <bdo id='9KCYp'></bdo><ul id='9KCYp'></ul>

                  <tbody id='9KCYp'></tbody>
              • <i id='9KCYp'><tr id='9KCYp'><dt id='9KCYp'><q id='9KCYp'><span id='9KCYp'><b id='9KCYp'><form id='9KCYp'><ins id='9KCYp'></ins><ul id='9KCYp'></ul><sub id='9KCYp'></sub></form><legend id='9KCYp'></legend><bdo id='9KCYp'><pre id='9KCYp'><center id='9KCYp'></center></pre></bdo></b><th id='9KCYp'></th></span></q></dt></tr></i><div id='9KCYp'><tfoot id='9KCYp'></tfoot><dl id='9KCYp'><fieldset id='9KCYp'></fieldset></dl></div>
                <legend id='9KCYp'><style id='9KCYp'><dir id='9KCYp'><q id='9KCYp'></q></dir></style></legend>
                  本文介绍了Python 的 SMTP AUTH 扩展问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试编写一个简单的 Python 脚本来通过我公司的 SMTP 服务器发送电子邮件.我正在使用以下代码.

                  I am trying to write a simple Python script to send emails through my company's SMTP server. I am using the following piece of code.

                  #! /usr/local/bin/python
                  
                  import sys,re,os,datetime
                  from smtplib import SMTP
                  
                  #Email function
                  def sendEmail(message):
                          sender="SENDERID@COMPANY.com"
                          receivers=['REVEIVER1@COMPANY.com','RECEIVER2@COMPANY.com']
                          subject="Daily Report - " + datetime.datetime.now().strftime("%d %b %y")
                          header="""
                                  From: %s
                                  To: %s
                                  Subject: %s
                  
                                  %s""" % (sender, ", ".join(receivers), subject, message)
                          smtp = SMTP()
                          smtp.set_debuglevel(1)
                          smtp.connect('X.X.X.X')
                          smtp.ehlo()
                          smtp.starttls()
                          smtp.ehlo()
                          try:
                                  smtp.login('SENDERID@COMPANY.com', '********')
                                  smtp.sendmail(sender,receivers,header)
                                  smtp.quit()
                          except Exception, e:
                                  print e
                  
                  #MAIN
                  sendEmail("HAHHAHAHAHAH!!!")
                  

                  运行这个程序,产生这个结果.

                  Running this program, yields this result.

                  connect: ('X.X.X.X', 25)
                  connect: ('X.X.X.X', 25)
                  reply: '220 COMPANY.com [ESMTP Server] service ready;ESMTP Server; 05/25/11 15:59:27
                  '
                  reply: retcode (220); Msg: COMPANY.com [ESMTP Server] service ready;ESMTP Server; 05/25/11 15:59:27
                  connect: COMPANY.com [ESMTP Server] service ready;ESMTP Server; 05/25/11 15:59:27
                  send: 'ehlo SERVER1.COMPANY.com
                  '
                  reply: '250-COMPANY.com
                  '
                  reply: '250-SIZE 15728640
                  '
                  reply: '250-8BITMIME
                  '
                  reply: '250 STARTTLS
                  '
                  reply: retcode (250); Msg: COMPANY.com
                  SIZE 15728640
                  8BITMIME
                  STARTTLS
                  send: 'STARTTLS
                  '
                  reply: '220 Ready to start TLS
                  '
                  reply: retcode (220); Msg: Ready to start TLS
                  send: 'ehlo SERVER2.COMPANY.com
                  '
                  reply: '250-COMPANY.com
                  '
                  reply: '250-SIZE 15728640
                  '
                  reply: '250 8BITMIME
                  '
                  reply: retcode (250); Msg: COMPANY.com
                  SIZE 15728640
                  8BITMIME
                  send: 'quit
                  '
                  reply: '221 [ESMTP Server] service closing transmission channel
                  '
                  reply: retcode (221); Msg: [ESMTP Server] service closing transmission channel
                  ERROR: Could not send email! Check the reason below.
                  SMTP AUTH extension not supported by server.
                  

                  如何开始调试此服务器不支持 SMTP AUTH 扩展".错误?

                  How do I start debugging this "SMTP AUTH extension not supported by server." error?

                  P.S.:我知道 SMTP 详细信息和凭据是正确的,因为我有一个包含确切详细信息的工作 Java 类.

                  P.S.: I know the SMTP details and credentials are correct, as I have a working Java class with the exact details.

                  推荐答案

                  你得到的错误意味着你正在与之交谈的 SMTP 服务器不声称支持身份验证.如果您查看调试输出,您会发现对 EHLO 的响应均不包含 AUTH 的必要声明.如果它确实(正确)支持身份验证,则其中一个响应将类似于:

                  The error you get means the SMTP server you're talking to doesn't claim to support authentication. If you look at the debug output you'll see that none of the responses to your EHLOs contain the necessary declaration for AUTH. If it did (properly) support authentication, one of the responses would be something like:

                  250 AUTH GSSAPI DIGEST-MD5 PLAIN
                  

                  (至少响应 STARTTLS 之后的 EHLO.)因为不包括该响应,smtplib 假定服务器将无法处理AUTH 命令,会拒绝发送.如果你确定你的 SMTP 服务器确实支持 AUTH 命令,即使它没有做广告,你可以偷偷地说服 smtplib 它支持 AUTH 通过将其显式添加到功能集.您需要知道支持哪种身份验证方案,然后您可以这样做:

                  (at least in reponse to the EHLO after the STARTTLS.) Because that response isn't included, smtplib assumes the server won't be able to handle the AUTH command, and will refuse to send it. If you're certain your SMTP server does support the AUTH command even though it doesn't advertise it, you can sneakily convince smtplib that it supports AUTH by explicitly adding it to the set of features. You'll need to know which kind of authentication schemes are supported, and then you can do:

                  smtp.starttls()
                  smtp.ehlo()
                  # Pretend the SMTP server supports some forms of authentication.
                  smtp.esmtp_features['auth'] = 'LOGIN DIGEST-MD5 PLAIN'
                  

                  ...当然,让 SMTP 服务器按照规范运行会是一个更好的主意 :)

                  ... but of course making the SMTP server behave according to spec would be a better idea :)

                  这篇关于Python 的 SMTP AUTH 扩展问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 Python smtplib 发送没有密钥文件(仅证书文件)的电子邮件 下一篇:Python:发送电子邮件时,总是在子句中被阻止:smtpserver = smtplib.SMTP("smt

                  相关文章

                  1. <tfoot id='J3ihi'></tfoot>
                  2. <small id='J3ihi'></small><noframes id='J3ihi'>

                        <bdo id='J3ihi'></bdo><ul id='J3ihi'></ul>
                    1. <i id='J3ihi'><tr id='J3ihi'><dt id='J3ihi'><q id='J3ihi'><span id='J3ihi'><b id='J3ihi'><form id='J3ihi'><ins id='J3ihi'></ins><ul id='J3ihi'></ul><sub id='J3ihi'></sub></form><legend id='J3ihi'></legend><bdo id='J3ihi'><pre id='J3ihi'><center id='J3ihi'></center></pre></bdo></b><th id='J3ihi'></th></span></q></dt></tr></i><div id='J3ihi'><tfoot id='J3ihi'></tfoot><dl id='J3ihi'><fieldset id='J3ihi'></fieldset></dl></div>
                      <legend id='J3ihi'><style id='J3ihi'><dir id='J3ihi'><q id='J3ihi'></q></dir></style></legend>