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

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

        <legend id='MS4sf'><style id='MS4sf'><dir id='MS4sf'><q id='MS4sf'></q></dir></style></legend>
      1. <tfoot id='MS4sf'></tfoot>

      2. 使用 smtplib - Python 接收来自 Gmail 的回复

        时间:2023-10-20
        • <small id='1IT4R'></small><noframes id='1IT4R'>

            <tbody id='1IT4R'></tbody>
            <bdo id='1IT4R'></bdo><ul id='1IT4R'></ul>

            <legend id='1IT4R'><style id='1IT4R'><dir id='1IT4R'><q id='1IT4R'></q></dir></style></legend>
            1. <tfoot id='1IT4R'></tfoot>
                <i id='1IT4R'><tr id='1IT4R'><dt id='1IT4R'><q id='1IT4R'><span id='1IT4R'><b id='1IT4R'><form id='1IT4R'><ins id='1IT4R'></ins><ul id='1IT4R'></ul><sub id='1IT4R'></sub></form><legend id='1IT4R'></legend><bdo id='1IT4R'><pre id='1IT4R'><center id='1IT4R'></center></pre></bdo></b><th id='1IT4R'></th></span></q></dt></tr></i><div id='1IT4R'><tfoot id='1IT4R'></tfoot><dl id='1IT4R'><fieldset id='1IT4R'></fieldset></dl></div>
                  本文介绍了使用 smtplib - Python 接收来自 Gmail 的回复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  好的,我正在开发一种系统,以便我可以通过短信在我的计算机上开始操作.我可以让它发送初始消息:

                  Ok, I am working on a type of system so that I can start operations on my computer with sms messages. I can get it to send the initial message:

                  import smtplib  
                  
                  fromAdd = 'GmailFrom'  
                  toAdd  = 'SMSTo'  
                  msg = 'Options 
                  H - Help 
                  T - Terminal'  
                  
                  username = 'GMail'  
                  password = 'Pass'  
                  
                  server = smtplib.SMTP('smtp.gmail.com:587')  
                  server.starttls()  
                  server.login(username , password)  
                  server.sendmail(fromAdd , toAdd , msg)  
                  server.quit()
                  

                  我只需要知道如何等待回复或从 Gmail 本身提取回复,然后将其存储在变量中以供以后使用.

                  I just need to know how to wait for the reply or pull the reply from Gmail itself, then store it in a variable for later functions.

                  推荐答案

                  您应该使用 POP3 或 IMAP(后者更可取),而不是用于发送电子邮件的 SMTP.使用 SMTP 的示例(代码不是我的,请参阅下面的 url 了解更多信息):

                  Instead of SMTP which is used for sending emails, you should use either POP3 or IMAP (the latter is preferable). Example of using SMTP (the code is not mine, see the url below for more info):

                  import imaplib
                  mail = imaplib.IMAP4_SSL('imap.gmail.com')
                  mail.login('myusername@gmail.com', 'mypassword')
                  mail.list()
                  # Out: list of "folders" aka labels in gmail.
                  mail.select("inbox") # connect to inbox.
                  
                  result, data = mail.search(None, "ALL")
                  
                  ids = data[0] # data is a list.
                  id_list = ids.split() # ids is a space separated string
                  latest_email_id = id_list[-1] # get the latest
                  
                  result, data = mail.fetch(latest_email_id, "(RFC822)") # fetch the email body (RFC822) for the given ID
                  
                  raw_email = data[0][1] # here's the body, which is raw text of the whole email
                  # including headers and alternate payloads
                  

                  从这里

                  这篇关于使用 smtplib - Python 接收来自 Gmail 的回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:SMTPAuthenticationError 5.7.14 请通过网络浏览器登录 5.7.14 下一篇:使用 python 从 gmail 下载 csv 文件

                  相关文章

                • <legend id='UI5cK'><style id='UI5cK'><dir id='UI5cK'><q id='UI5cK'></q></dir></style></legend>

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

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

                    1. <tfoot id='UI5cK'></tfoot>