Skip to main content

mail_admins

Function mail_admins 

Source
pub async fn mail_admins(
    mailer: &dyn Mailer,
    s: &MailSettings,
    subject: impl Into<String>,
    body: impl Into<String>,
) -> Result<usize, MailError>
Expand description

Django-shape mail_admins(subject, message) — sends to the addresses configured in MailSettings.admins. Returns Ok(0) when the list is empty (a no-op without warning, matching Django’s “no ADMINS → silent skip” behavior). Issue #416.

subject is prefixed with "[admin] " to match Django’s default EMAIL_SUBJECT_PREFIX. Override the subject yourself if you need a different prefix.

from falls back to MailSettings.from_address; if neither is set the mailer’s Email::validate() will surface a MailError::InvalidMessage.

§Errors

Forwarded from the mailer’s send call. Returns Ok(count) on success — count is the number of recipients the message went to.