Skip to main content

send_mail

Easy wrapper for sending a single message to a recipient list. All members of the recipient list will see the other recipients in the 'To' field.

def send_mail(
subject: string,
message: string,
from_email: string,
recipient_list: list,
fail_silently: boolean = False,
auth_user: string = None,
auth_password: string = None,
connection: EmailBackend = None,
html_message: string = None,
using: string = None
) - > int

Easy wrapper for sending a single message to a recipient list. All members of the recipient list will see the other recipients in the 'To' field.

Parameters

NameTypeDescription
subjectstringThe subject line of the email.
messagestringThe plain-text body of the email.
from_emailstringThe sender's email address; if None, the DEFAULT_FROM_EMAIL setting is used.
recipient_listlistA list of strings, each an email address of a recipient.
fail_silentlyboolean = FalseWhether to suppress exceptions raised during the sending process.
auth_userstring = NoneThe username to use for authenticating with the SMTP server.
auth_passwordstring = NoneThe password to use for authenticating with the SMTP server.
connectionEmailBackend = NoneAn optional email backend instance to use for sending the mail.
html_messagestring = NoneAn optional HTML version of the message body to be sent as a multipart/alternative.
usingstring = NoneThe name of the email backend alias to use for sending the message.

Returns

TypeDescription
intThe number of successfully delivered messages (typically 1 if successful).