Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

flask_mail

pip install Flask-Mail
Comment

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'] = '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 :: print hello world in python 
Python :: python regex find first 
Python :: python get day month year 
Python :: The operands of the logical operators should be boolean expressions, but Python is not very strict. Any nonzero number is interpreted as True. 
Python :: change default python version 
Python :: append element to an array python 
Python :: pandas remove item from dictionary 
Python :: python file location path 
Python :: adjust size of plot 
Python :: find the area of a circle in python 
Python :: make directory python 
Python :: accessing data on django sessionstore 
Python :: ipython on cmd 
Python :: colab add library 
Python :: numpy check if 2 array identical 
Python :: create a df in pandas 
Python :: how to make a full pyramid in python 
Python :: how to use variables in string in python 
Python :: how to extract numbers from a list in python 
Python :: python print in one line 
Python :: how to print a string by reverse way in python 
Python :: python process memory usage 
Python :: multiple inputs in python 
Python :: python ascii caesar cipher 
Python :: python get name of function 
Python :: python procedured 
Python :: python create environment linux 
Python :: lecture de fichier python 
Python :: python selenium set attribute of element 
Python :: ascii to decimal python 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =