pip install -r requirement.txt
- To use flask_mail with Amazon SES, you will need to configure your application to use the Amazon SES SMTP interface. Here's how you can do it
pip install boto3
MAIL_SERVER = 'email-smtp.us-east-1.amazonaws.com'
MAIL_PORT = 587
MAIL_USE_TLS = True
MAIL_USERNAME = 'your_ses_smtp_username'
MAIL_PASSWORD = 'your_ses_smtp_password'
MAIL_DEFAULT_SENDER = 'your_default_sender_email_address'
Create a SendGrid account and obtain an API key. You can sign up for a free account at https://sendgrid.com/free/.
pip install sendgrid
MAIL_SERVER = 'smtp.sendgrid.net'
MAIL_PORT = 587
MAIL_USE_TLS = True
MAIL_USERNAME = 'apikey'
MAIL_PASSWORD = 'your_sendgrid_api_key'
MAIL_DEFAULT_SENDER = 'your_default_sender_email_address'
from flask_mail import Message
message = Message(subject='Hello from Flask-Mail',
recipients=['recipient@example.com'])
message.body = 'This is a test email sent from Flask-Mail using SendGrid.'
mail.send(message)