Flask's Email extension

Source: Internet
Author: User

4.4 Flask-mail

In the development process, many applications need to notify the user via mail, Flask extension Package flask-mail by wrapping Python built-in Smtplib package, can be used in the Flask program to send mail.

The Flask-mail connects to the Simple Mail protocol (easy Mail Transfer protocol,smtp) server and sends the message to the server.

The following example sends a message by turning on the QQ mailbox SMTP service settings.

 fromFlaskImportFlask fromFlask_mailImportMail, Messageapp= Flask (__name__)#Configure mail: Server/port/Transport Layer Security Protocol/mailbox name/passwordapp.config.update (DEBUG=True, Mail_server='smtp.qq.com', Mail_prot=465, Mail_use_tls=True, Mail_username='[email protected]', Mail_password='Goyubxohbtzfbidd',) Mail=Mail (APP) @app. Route ('/')defindex ():#Sender sender, recipients receiver listmsg = Message ("This is a test", sender='[email protected]', recipients=['[email protected]','[email protected]'])    #Message ContentMsg.body ="Flask Test Mail"    #Send mailmail.send (msg)Print "Mail sent"    return "Sent succeed"if __name__=="__main__": App.run ()

Flask Message Extensions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.