Skip to content

Commit 80a788d

Browse files
committed
Doc: Update send email using sendgrid with sendgrid tutorial
1 parent 642b5f8 commit 80a788d

9 files changed

+27
-0
lines changed
88.5 KB
Loading
148 KB
Loading
Loading
160 KB
Loading
Loading
142 KB
Loading
Loading
166 KB
Loading

twilio_sendgrid/02_send_emails_using_sendgrid.md

+27
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,30 @@ Click on "Verify A Single Sender".
9696

9797
![Verify A Single Sender](/images/sendgrid/send_emails/verify_a_single_sender.png)
9898

99+
You will be redirected to a new page where you can create your sender. Once done, click "Create".
100+
101+
![Create new sender](/images/sendgrid/send_emails/create_new_sender.png)
102+
103+
This sender's email address, once verified, should be used as the `MAIL_DEFAULT_SENDER` value in `.env`.
104+
105+
106+
## Sending Email
107+
108+
To illustrate how to send an email in your Flask app, we will use the terminal. Activate the shell by running `flask shell`:
109+
110+
```python
111+
(venv)$ flask shell
112+
```
113+
114+
And now, to send an email, we can do the following:
115+
116+
```python
117+
>>> from flask_mail import Message
118+
>>> from app import mail
119+
>>> msg = Message("[Test] My Subject", recipients=["[email protected]"])
120+
>>> msg.body = "This is a text body"
121+
>>> msg.html = "<p>This is an HTML body</p>"
122+
>>> mail.send(msg)
123+
```
124+
125+
That is it! Check your inbox for a new mail. Hope everything went well. If you would like to learn how to use a graphical user interface to send an email using SendGrid, learn how to do that [here](/email_support_in_flask.md#sending-password-reset-email).

0 commit comments

Comments
 (0)