Extra content of flask application
1.emial setup in flask application
from flask import Flask, render_template
from flask_mail import Mail, Message
EMAIL_ADDRESS = ''
EMAIL_PASSWORD = ''
app = Flask(__name__)
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = EMAIL_ADDRESS
app.config['MAIL_PASSWORD'] = EMAIL_PASSWORD
app.config['MAIL_DEFAULT_SENDER'] = ('username', EMAIL_ADDRESS) # Default sender
mail = Mail(app)
@app.route('/mail')
def send_email():
with app.app_context():
html_content = render_template('email_template.html', subject='Confiramation mail', greeting='Good Morning!',
body='congratulation you have successfully passed examanation.', sender=EMAIL_ADDRESS)
msg = Message('Email From flask application', recipients=['amritpanta77@gmail.com'])
# msg.body = 'This is the body of the email.'
msg.html = html_content
mail.send(msg)
return 'Email sent successfully'
if __name__ == '__main__':
app.run(debug=True)
or if you need simply test mail then ,
with app.app_context():
msg = Message('subject', recipients=['amritpanta77@gmail.com'])
msg.body = 'body'
msg.sender = EMAIL_ADDRESS
mail.send(msg)
Amanda Martines 5 days ago
Exercitation photo booth stumptown tote bag Banksy, elit small batch freegan sed. Craft beer elit seitan exercitation, photo booth et 8-bit kale chips proident chillwave deep v laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do umami readymade swag. Selfies iPhone Kickstarter, drinking vinegar jean.
ReplyBaltej Singh 5 days ago
Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.
ReplyMarie Johnson 5 days ago
Kickstarter seitan retro. Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.
Reply