Email sender
SG_FROM_EMAIL = '[email protected]'
module-attribute
SG_FROM_NAME = 'Tim'
module-attribute
sg_client = sendgrid.SendGridAPIClient(api_key=settings.SENDGRID_API_KEY)
module-attribute
MessageValidator
Bases: BaseModel
content
instance-attribute
from_email
instance-attribute
subject
instance-attribute
to_email
instance-attribute
escape_html(value)
classmethod
send_email(content, subject, to_email=None, from_email=SG_FROM_EMAIL, client=None)
async
Send an email using SendGrid.
| PARAMETER | DESCRIPTION |
|---|---|
content
|
The email content.
TYPE:
|
subject
|
The email subject.
TYPE:
|
to_email
|
The email recipient.
TYPE:
|
from_email
|
The email to send from (note: must be verified in SendGrid first).
TYPE:
|
client
|
The SendGrid client to use.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValidationError
|
If emails/content are invalid. |
HTTPError
|
If SendGrid API request fails. |