Emails

The django-logikal library provides the Email class as the main interface for sending emails.

class django_logikal.email.Email(template: str, context: Optional[Mapping[str, Any]] = None, prefix: Optional[str] = None)

Create an email based on a template.

Note

Requires the dynamic extra and a valid Anymail configuration.

Tip

We recommend using the standard dynamic_site settings module, which configures the Amazon SES Anymail ESP with the standard Stormware AWS authentication process.

Parameters
  • template – The template to use.

  • context – The context to use for template rendering.

  • prefix – The prefix to use for the subject. Defaults to the value of the EMAIL_SUBJECT_PREFIX setting. Note that a space is automatically appended to the provided value.

Template

Tip

We recommend extending the standard email base template.

Blocks

subject

The email’s subject (required).

text

The plain text version of the email (optional). Defaults to the Markdown version of the rendered HTML content.

Functions

image(path: Union[str, Path]) str

Add an inline image from a local path to the email and return the image source string.

Methods & Properties

attach(filename: Union[str, MIMEBase], content: Optional[Any] = None, mimetype: Optional[str] = None) None

Create a new file attachment and add it to the message.

See attach() in django.core.mail.EmailMessage.

attach_file(path: Union[str, Path], mimetype: Optional[str] = None) None

Create a new attachment using a file from the filesystem.

See attach_file() in django.core.mail.EmailMessage.

send(sender: str, to: Sequence[str], cc: Optional[Sequence[str]] = None, bcc: Optional[Sequence[str]] = None, reply_to: Optional[Sequence[str]] = None) int

Send the email.

Parameters
  • sender – The sender’s address.

  • to – A list of recipients.

  • cc – A list of carbon copy recipients.

  • bcc – A list of blind carbon copy recipients.

  • reply_to – A list of addresses for replies.

property status: AnymailStatus

Return the status of the email.