Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

flask_mail

pip install Flask-Mail
Comment

flask mail python

# 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'] = 'yourId@gmail.com'
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 = 'yourId@gmail.com', recipients = ['someone1@gmail.com'])
   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)
Comment

sending email with flask_mail

from flask import Flask
from flask_mail import Mail

app = Flask(__name__)
mail = Mail(app)
Comment

PREVIOUS NEXT
Code Example
Python :: how shorten with enter long script python 
Python :: python add to list with index 
Python :: pathlib current directory 
Python :: create 2d list dictionary 
Python :: set python 3 as default ubuntu 
Python :: plotly update legend title 
Python :: how to find no of times a elements in list python 
Python :: how to check if item is file in python or not 
Python :: plt.plot figure size 
Python :: request.body django 
Python :: hello world py 
Python :: sending email in django 
Python :: scikit learn k means 
Python :: colab add package 
Python :: np shuffle 
Python :: python typed list 
Python :: rename index 
Python :: flask render_template 
Python :: register temporary table pyspark 
Python :: maping value to data in pandas dataframe 
Python :: how to read a text file from url in python 
Python :: error urllib request no attribute 
Python :: drop row pandas 
Python :: replace nat with date pandas 
Python :: python download for ubuntu 20.04 
Python :: tkinter button command with arguments 
Python :: make dataframe index a column 
Python :: django iterate over all objects 
Python :: python obtain data from pandas dataframe without index name 
Python :: convert string to class name python 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =