<bdo id='rfxn7'></bdo><ul id='rfxn7'></ul>

      <legend id='rfxn7'><style id='rfxn7'><dir id='rfxn7'><q id='rfxn7'></q></dir></style></legend>
    1. <small id='rfxn7'></small><noframes id='rfxn7'>

      <tfoot id='rfxn7'></tfoot>

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

        我正在尝试使用 web2py 和 gmail 发送电子邮件并使用 smtp 设置我已附加所有代码

        时间:2023-07-03

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

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

              <tfoot id='SjXwb'></tfoot>
                  <tbody id='SjXwb'></tbody>
                • <bdo id='SjXwb'></bdo><ul id='SjXwb'></ul>
                  本文介绍了我正在尝试使用 web2py 和 gmail 发送电子邮件并使用 smtp 设置我已附加所有代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 web2py 中创建一个表单,该表单在提交时将消息发送到电子邮件帐户主要是我使用 SQLFORM.factory 创建表单,然后我使用 gluon.tools import mail 导入发送电子邮件功能.我已经设置了我能想到的所有东西,但仍然在 web2py 中运行此代码,它给出了未能发送电子邮件抱歉".

                  i am trying to create a form in web2py which sends message to an email account on submission mainly i used SQLFORM.factory to create the form then i used gluon.tools import mail to import the send email functionality. i have set up everything i can think of but still on running this code in web2py it gives out that "fail to send email sorry".

                  from gluon.tools import Mail
                  mail = Mail()
                  
                  mail.settings.server = 'smtp@gmail.com:465'
                  mail.settings.sender = 'myemail@gmail.com'
                  mail.settings.login = 'myemail@gmail.com:secret'
                  
                  
                  
                  
                  def index(): 
                  
                      form = SQLFORM.factory(
                      Field('name', requires=IS_NOT_EMPTY()),
                      Field('email', requires =[ IS_EMAIL(error_message='invalid email!'), IS_NOT_EMPTY() ]),
                      Field('subject', requires=IS_NOT_EMPTY()),
                      Field('message', requires=IS_NOT_EMPTY(), type='text')
                      )
                      if form.process().accepted:
                          session.name = form.vars.name
                          session.email = form.vars.email
                          session.subject = form.vars.subject
                          session.message = form.vars.message
                  
                          x = mail.send(to=['otheremail@yahoo.com'],
                              subject='project minerva',
                              message= "Hello this is an email send from minerva.com from contact us form.
                  Name:"+ session.name+" 
                  Email : " + session.email +"
                  Subject : "+session.subject +"
                  Message : "+session.message+ ".
                   "
                          )
                  
                          if x == True:
                              response.flash = 'email sent sucessfully.'
                          else:
                              response.flash = 'fail to send email sorry!'
                  
                          #response.flash = 'form accepted.'
                      elif form.errors:
                          response.flash='form has errors.'
                  
                      return dict(form=form)
                  

                  推荐答案

                  在使用 mail.send() 之前,我建议测试一下邮件是否设置正确:

                  Before using mail.send() I would recommend to test if mail is correctly set :

                  if form.process().accepted:
                      session.name = form.vars.name
                      session.email = form.vars.email
                      session.subject = form.vars.subject
                      session.message = form.vars.message
                      if mail:
                          if mail.send(to=['otheremail@yahoo.com'],
                              subject='project minerva',
                              message= "Hello this is an email send from minerva.com from contact us form.
                  Name:"+ session.name+" 
                  Email : " + session.email +"
                  Subject : "+session.subject +"
                  Message : "+session.message+ ".
                   "
                          ):
                              response.flash = 'email sent sucessfully.'
                          else:
                              response.flash = 'fail to send email sorry!'
                      else:
                          response.flash = 'Unable to send the email : email parameters not defined'
                  elif form.errors:
                          response.flash='form has errors.'
                  

                  然后尝试改变:

                  mail.settings.server = 'smtp@gmail.com:465'
                  

                  mail.settings.server = 'smtp.gmail.com:465'
                  

                  mail.settings.server = 'smtp.gmail.com:587'
                  

                  这篇关于我正在尝试使用 web2py 和 gmail 发送电子邮件并使用 smtp 设置我已附加所有代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:带有正文内容的 Python 电子邮件多部分 下一篇:Python smtplib:Gmail 有效,但仅“有时"

                  相关文章

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

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