Sending Emails
This section covers the basics of sending emails.
We use an EmailSender configured in Configuring Email.
Sending Email with Text Body
To send an email with plain text message:
email.send(
subject='email subject',
receivers=['first.last@example.com'],
text="Hi, this is an email."
)
Sending Email with HTML Body
To send an email with html content:
email.send(
subject='email subject',
receivers=['first.last@example.com'],
html="""
<h1>Hi,</h1>
<p>this is an email.</p>
"""
)
Sending Email with text and HTML Body
You can also include both to your email:
email.send(
subject='email subject',
receivers=['first.last@example.com'],
text="Hi, this is an email.",
html="""
<h1>Hi,</h1>
<p>this is an email.</p>
"""
)
Sending Email with cc and bcc
You can also include carbon copy (cc) and blind carbon copy (bcc) to your emails:
email.send(
subject='email subject',
receivers=['first.last@example.com'],
cc=['also@example.com'],
bcc=['outsider@example.com']
)