Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

flask_mail

pip install Flask-Mail
Comment

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

PREVIOUS NEXT
Code Example
Python :: find a file in python 
Python :: rsplit string from last 
Python :: drf default pagination 
Python :: python dictionary to csv 
Python :: python replace first 
Python :: get a list of ids from queryset django 
Python :: numpy get index of n largest values 
Python :: plt imshow python 
Python :: django template for range 
Python :: if keyboard.is_pressed 
Python :: print a text in python 
Python :: drop duplicate rows pandas except nan 
Python :: discord.py get guild member list 
Python :: colab install library 
Python :: pyhton regex to find string in file 
Python :: dropna for specific column pandas 
Python :: python solve equation with two variables 
Python :: boto3 upload file to s3 
Python :: pyqt loading screen 
Python :: show all columns pandas jupyter notebook 
Python :: print % in python 
Python :: blinking an led with raspberry pi 
Python :: python day of the week 
Python :: how to print to a file in python 
Python :: python folder exists 
Python :: string startswith python 
Python :: Getting the Current Working Directory in Python 
Python :: python print for loop one line 
Python :: pytest check exception 
Python :: python web parser 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =