Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 邮件:OSError:[Errno 2]没有这样的文件或目录_Python_Flask_Flask Mail - Fatal编程技术网

Python 邮件:OSError:[Errno 2]没有这样的文件或目录

Python 邮件:OSError:[Errno 2]没有这样的文件或目录,python,flask,flask-mail,Python,Flask,Flask Mail,OSError:[Errno 2]当我尝试使用电子邮件发送邮件时,没有这样的文件或目录。 下面是我的代码: app.config['MAIL_SERVER']='smtp.gmail.com' app.config['MAIL_PORT'] = 465 app.config['MAIL_USERNAME'] = parametter.email_sender app.config['MAIL_PASSWORD'] = parametter.

OSError:[Errno 2]当我尝试使用电子邮件发送邮件时,没有这样的文件或目录。 下面是我的代码:

       app.config['MAIL_SERVER']='smtp.gmail.com'
       app.config['MAIL_PORT'] = 465
       app.config['MAIL_USERNAME'] = parametter.email_sender
       app.config['MAIL_PASSWORD'] = parametter.email_sender_password
       app.config['MAIL_USE_TLS'] = False
       app.config['MAIL_USE_SSL'] = False
       mail = Mail(app)
      @app.route('/')
      def main():
               msg = Message('Hello', sender = parametter.email_sender,recipients = [parametter.email_recipients])
               msg.body = "Hello Flask message sent from Flask-Mail"
               mail.send(msg)
               return "Sent"

当我注释(#mail.send(msg))时,程序正常运行。但是我不能发送消息。有人能帮我回答这个问题吗?

导入库时出错:

from flask.ext.mail import Mail, Message
应该是:

from flask_mail import Mail, Message