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

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

      • <bdo id='B9cn8'></bdo><ul id='B9cn8'></ul>
      <legend id='B9cn8'><style id='B9cn8'><dir id='B9cn8'><q id='B9cn8'></q></dir></style></legend><tfoot id='B9cn8'></tfoot>
    2. Python 不向多个地址发送电子邮件

      Python Not Sending Email To Multiple Addresses(Python 不向多个地址发送电子邮件)
        <tbody id='9v5LK'></tbody>

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

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

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

                <legend id='9v5LK'><style id='9v5LK'><dir id='9v5LK'><q id='9v5LK'></q></dir></style></legend>
              • 本文介绍了Python 不向多个地址发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我看不出我哪里出了问题,我希望有人能发现问题.我想向多个地址发送电子邮件;但是,它只会将其发送到列表中的第一个电子邮件地址,而不是同时发送到两者.代码如下:

                I can't see where i'm going wrong with this, I hope someone can spot the problem. I'd like to send an email to multiple addresses; however, it only sends it to the first email address in the list and not both. Here's the code:

                import smtplib
                from smtplib import SMTP
                
                recipients = ['example1@gmail.com', 'example2@example.com']
                
                def send_email (message, status):
                    fromaddr = 'from@gmail.com'
                    toaddrs = ", ".join(recipients)
                    server = SMTP('smtp.gmail.com:587')
                    server.ehlo()
                    server.starttls()
                    server.ehlo()
                    server.login('example_username', 'example_pw')
                    server.sendmail(fromaddr, toaddrs, 'Subject: %s
                %s' % (status, message))
                    server.quit()
                
                 send_email("message","subject")
                

                以前有人遇到过这个错误吗?

                Has anyone came across this error before?

                感谢您的宝贵时间.

                推荐答案

                尝试使用此代码,无需您的加入:

                Try to use this code, without your join:

                import smtplib
                from smtplib import SMTP
                
                recipients = ['example1@gmail.com', 'example2@example.com']
                
                def send_email (message, status):
                    fromaddr = 'from@gmail.com'
                    server = SMTP('smtp.gmail.com:587')
                    server.ehlo()
                    server.starttls()
                    server.ehlo()
                    server.login('example_username', 'example_pw')
                    server.sendmail(fromaddr, recipients, 'Subject: %s
                %s' % (status, message))
                    server.quit()
                
                 send_email("message","subject")
                

                希望对你有帮助!

                这篇关于Python 不向多个地址发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                  <tbody id='L8chp'></tbody>

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

                    1. <small id='L8chp'></small><noframes id='L8chp'>

                    2. <tfoot id='L8chp'></tfoot>
                      • <bdo id='L8chp'></bdo><ul id='L8chp'></ul>