Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the integration guide for SendGrid as a reference to support sending emails #696

Merged
merged 1 commit into from
Dec 27, 2022

Conversation

csharplus
Copy link
Collaborator

@csharplus csharplus commented Dec 26, 2022

Description of changeset:

A working example app.py for email integration is provided based on SendGrid, as listed below:

# app.py

from flask import Flask
from flask_mail import Mail, Message

app = Flask(__name__)
app.config["SECRET_KEY"] = "top-secret!"
app.config["MAIL_SERVER"] = "smtp.sendgrid.net"
app.config["MAIL_PORT"] = 587
app.config["MAIL_USE_TLS"] = True
app.config["MAIL_USERNAME"] = "apikey"
app.config[
    "MAIL_PASSWORD"
] = "<Get it from SendGrid>"
app.config["MAIL_DEFAULT_SENDER"] = "<Test sender email>"


with app.app_context():
    mail = Mail(app)
    msg = Message("Twilio SendGrid Test Email", recipients=["<Test recipient email>"])
    msg.body = "This is a test email!"
    msg.html = "<p>This is a test email!</p>"
    mail.send(msg)

To run this example, please get the MAIL_PASSWORD (i.e., API_KEY) following the instructions given by SendGrid at here, then run the following commands in a terminal:

$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ pip install flask flask-mail
(venv) $ python3 app.py

Test Plan:
CI

Reviewers:
@JJJ000 @mengting1010

@csharplus csharplus self-assigned this Dec 26, 2022
@csharplus
Copy link
Collaborator Author

@JJJ000 @mengting1010 PTAL

Copy link
Collaborator

@mengting1010 mengting1010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@csharplus csharplus merged commit b15c759 into master Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants