“Python Flask Mail” Kode Jawaban

Python Flask Mail

# In your command line run: 
# pip install Flask-Mail

# Then you can start sending emails easily! Enjoy! :)
from flask import Flask
from flask_mail import Mail, Message

app = Flask(__name__)

app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = '[email protected]'
app.config['MAIL_PASSWORD'] = '*****'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True // True if Port = 465
mail = Mail(app)

@app.route("/")
def index():
   msg = Message('Hello', sender = '[email protected]', recipients = ['[email protected]'])
   msg.body = "Hello Flask message sent from Flask-Mail"
   
   # You can also use msg.html to send html templates!
   # Example:
   # msg.html = render_template("hello.html") # Template should be in 'templates' folder
   
   mail.send(msg)
   return "Your email has been sent!"

if __name__ == '__main__':
   app.run(debug = True)
S3NS4

flask_mail

pip install Flask-Mail
Mysterious Mosquito

Jawaban yang mirip dengan “Python Flask Mail”

Pertanyaan yang mirip dengan “Python Flask Mail”

Lebih banyak jawaban terkait untuk “Python Flask Mail” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya