“Python Flask Mail” Kod odpowiedzi

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

Odpowiedzi podobne do “Python Flask Mail”

Pytania podobne do “Python Flask Mail”

Więcej pokrewnych odpowiedzi na “Python Flask Mail” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu