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

      <bdo id='R8XAH'></bdo><ul id='R8XAH'></ul>
    <legend id='R8XAH'><style id='R8XAH'><dir id='R8XAH'><q id='R8XAH'></q></dir></style></legend>
  • <small id='R8XAH'></small><noframes id='R8XAH'>

        使用 SMTPLib Python 时获取未经授权的发件人地址

        Getting unauthorized sender address when using SMTPLib Python(使用 SMTPLib Python 时获取未经授权的发件人地址)
      1. <tfoot id='5Cj3o'></tfoot>

        <small id='5Cj3o'></small><noframes id='5Cj3o'>

          <legend id='5Cj3o'><style id='5Cj3o'><dir id='5Cj3o'><q id='5Cj3o'></q></dir></style></legend>
            <tbody id='5Cj3o'></tbody>

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

                  本文介绍了使用 SMTPLib Python 时获取未经授权的发件人地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我编写了一个非常简单的 Python 脚本,用于自动发送电子邮件.这是它的代码:

                  I have a very simple Python script that I wrote to send out emails automatically. Here is the code for it:

                  import smtplib
                  
                  From = "LorenzoTheGabenzo@gmx.com"
                  To = ["LorenzoTheGabenzo@gmx.com"]
                  
                  with smtplib.SMTP('smtp.gmx.com', 587) as smtp:
                      smtp.ehlo()
                      smtp.starttls() 
                      smtp.ehlo()
                  
                      smtp.login("LorenzoTheGabenzo@gmx.com", Password)
                  
                      Subject = "Test"
                      Body = "TestingTheBesting"
                      Message = f"{Subject}
                  
                  {Body}"
                  
                      smtp.sendmail(From, To, Message)
                  

                  每当我运行此代码时,我都会收到一个非常奇怪的错误,告诉我此发件人是未经授权的发件人".这是完整的错误

                  Whenever I run this code I get a very strange error telling me that this sender is an "unauthorized sender". Here is the error in full

                  File "test.py", line 17, in <module>    smtp.sendmail(From, To, Message)
                    File "C:UsersJamesAppDataLocalProgramsPythonPython37-32libsmtplib.py", line 888, in sendmail888, in sendmail    raise SMTPDataError(code, resp)smtplib.SMTPDataError: (554, b'Transaction failed
                  Unauthorized sender address.')
                  

                  我已经在 GMX 设置中启用了 SMTP 访问,但我不确定现在还可以做些什么来解决这个问题.

                  I've already enabled SMTP access in the GMX settings and I'm unsure about what else to do now to fix this issue.

                  注意:我知道变量密码还没有定义.这是因为我在发布之前故意将其删除,它是在我的原始代码中定义的.

                  Note: I know that the variable password has not been defined. This is because I intentionally removed it before posting, it's defined in my original code.

                  推荐答案

                  GMX 检查邮件标头是否匹配标头中的发件人"条目和实际发件人.您提供了一个简单的字符串作为消息,因此没有标题,因此 GMX 出错.为了解决这个问题,您可以使用电子邮件包中的消息对象.

                  GMX checks a messages header for a match between the "From" entry in the header and the actual sender. You provided a simple string as message, so there is no header, and hence the error by GMX. In order to fix this, you can use a message object from the email package.

                  import smtplib
                  from email.mime.text import MIMEText
                  
                  Subject = "Test"
                  Body = "TestingTheBesting"
                  Message = f"{Subject}
                  
                  {Body}"
                  msg = MIMEText(Message)
                  
                  msg['From'] = "LorenzoTheGabenzo@gmx.com"
                  msg['To'] = ["LorenzoTheGabenzo@gmx.com"]
                  
                  with smtplib.SMTP('smtp.gmx.com', 587) as smtp:
                      smtp.ehlo()
                      smtp.starttls() 
                      smtp.ehlo()
                  
                      smtp.login("LorenzoTheGabenzo@gmx.com", Password)
                  
                  
                      smtp.sendmail(msg['From'], msg['To'], msg)
                  

                  这篇关于使用 SMTPLib Python 时获取未经授权的发件人地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  env: python: No such file or directory(env: python: 没有这样的文件或目录)
                  How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                  Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                  Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                  Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                  When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)
                    • <bdo id='5SG6W'></bdo><ul id='5SG6W'></ul>
                    • <i id='5SG6W'><tr id='5SG6W'><dt id='5SG6W'><q id='5SG6W'><span id='5SG6W'><b id='5SG6W'><form id='5SG6W'><ins id='5SG6W'></ins><ul id='5SG6W'></ul><sub id='5SG6W'></sub></form><legend id='5SG6W'></legend><bdo id='5SG6W'><pre id='5SG6W'><center id='5SG6W'></center></pre></bdo></b><th id='5SG6W'></th></span></q></dt></tr></i><div id='5SG6W'><tfoot id='5SG6W'></tfoot><dl id='5SG6W'><fieldset id='5SG6W'></fieldset></dl></div>
                        <tfoot id='5SG6W'></tfoot>

                        <small id='5SG6W'></small><noframes id='5SG6W'>

                            <tbody id='5SG6W'></tbody>
                            <legend id='5SG6W'><style id='5SG6W'><dir id='5SG6W'><q id='5SG6W'></q></dir></style></legend>