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. If from_email is None, use the DEFAULT_FROM_EMAIL setting. Note: The API for this method is frozen. New code wanting to extend the
(
subject,
message,
from_email,
recipient_list,
*,
fail_silently=False,
auth_user=None,
auth_password=None,
connection=None,
html_message=None,
using=None,
)
| 111 | ], |
| 112 | ) |
| 113 | def send_mail( |
| 114 | subject, |
| 115 | message, |
| 116 | from_email, |
| 117 | recipient_list, |
| 118 | *, |
| 119 | fail_silently=False, |
| 120 | auth_user=None, |
| 121 | auth_password=None, |
| 122 | connection=None, |
| 123 | html_message=None, |
| 124 | using=None, |
| 125 | ): |
| 126 | """ |
| 127 | Easy wrapper for sending a single message to a recipient list. All members |
| 128 | of the recipient list will see the other recipients in the 'To' field. |
| 129 | |
| 130 | If from_email is None, use the DEFAULT_FROM_EMAIL setting. |
| 131 | |
| 132 | Note: The API for this method is frozen. New code wanting to extend the |
| 133 | functionality should use the EmailMessage class directly. |
| 134 | """ |
| 135 | # RemovedInDjango70Warning: change entire implementation to: |
| 136 | # email = EmailMultiAlternatives( |
| 137 | # subject, message, from_email, recipient_list |
| 138 | # ) |
| 139 | # if html_message: |
| 140 | # email.attach_alternative(html_message, "text/html") |
| 141 | # return email.send(using=using) |
| 142 | if fail_silently: |
| 143 | warn_about_external_use( |
| 144 | FAIL_SILENTLY_ARG_WARNING, RemovedInDjango70Warning, skip_frames=1 |
| 145 | ) |
| 146 | if auth_user is not None or auth_password is not None: |
| 147 | warn_about_external_use( |
| 148 | AUTH_ARGS_WARNING, RemovedInDjango70Warning, skip_frames=1 |
| 149 | ) |
| 150 | if connection is not None: |
| 151 | warn_about_external_use( |
| 152 | CONNECTION_ARG_WARNING, RemovedInDjango70Warning, skip_frames=1 |
| 153 | ) |
| 154 | |
| 155 | if using is not None: |
| 156 | report_using_incompatibility( |
| 157 | connection, fail_silently, auth_user, auth_password |
| 158 | ) |
| 159 | elif connection is None: |
| 160 | options = {"fail_silently": fail_silently} |
| 161 | if auth_user is not None: |
| 162 | options["username"] = auth_user |
| 163 | if auth_password is not None: |
| 164 | options["password"] = auth_password |
| 165 | connection = get_connection(**options) |
| 166 | else: |
| 167 | if fail_silently: |
| 168 | raise TypeError( |
| 169 | "fail_silently cannot be used with a connection. " |
| 170 | "Pass fail_silently to get_connection() instead." |