MCPcopy
hub / github.com/django/django / send_mass_mail

Function send_mass_mail

django/core/mail/__init__.py:195–257  ·  view source on GitHub ↗

Given a datatuple of (subject, message, from_email, recipient_list), send each message to each recipient list. Return the number of emails sent. 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 f

(
    datatuple,
    *,
    fail_silently=False,
    auth_user=None,
    auth_password=None,
    connection=None,
    using=None,
)

Source from the content-addressed store, hash-verified

193 ],
194)
195def send_mass_mail(
196 datatuple,
197 *,
198 fail_silently=False,
199 auth_user=None,
200 auth_password=None,
201 connection=None,
202 using=None,
203):
204 """
205 Given a datatuple of (subject, message, from_email, recipient_list), send
206 each message to each recipient list. Return the number of emails sent.
207
208 If from_email is None, use the DEFAULT_FROM_EMAIL setting.
209
210 Note: The API for this method is frozen. New code wanting to extend the
211 functionality should use the EmailMessage class directly.
212 """
213 # RemovedInDjango70Warning: change entire implementation to:
214 # messages = [...]
215 # mailer = mailers.default if using is None else mailers[using]
216 # return mailer.send_messages(messages)
217 if fail_silently:
218 warn_about_external_use(
219 FAIL_SILENTLY_ARG_WARNING, RemovedInDjango70Warning, skip_frames=1
220 )
221 if auth_user is not None or auth_password is not None:
222 warn_about_external_use(
223 AUTH_ARGS_WARNING, RemovedInDjango70Warning, skip_frames=1
224 )
225 if connection is not None:
226 warn_about_external_use(
227 CONNECTION_ARG_WARNING, RemovedInDjango70Warning, skip_frames=1
228 )
229
230 if using is not None:
231 report_using_incompatibility(
232 connection, fail_silently, auth_user, auth_password
233 )
234 connection = mailers[using]
235 elif connection is None:
236 options = {"fail_silently": fail_silently}
237 if auth_user is not None:
238 options["username"] = auth_user
239 if auth_password is not None:
240 options["password"] = auth_password
241 connection = get_connection(**options)
242 else:
243 if fail_silently:
244 raise TypeError(
245 "fail_silently cannot be used with a connection. "
246 "Pass fail_silently to get_connection() instead."
247 )
248 if auth_user is not None or auth_password is not None:
249 raise TypeError(
250 "auth_user and auth_password cannot be used with a connection. "
251 "Pass auth_user and auth_password to get_connection() instead."
252 )

Calls 5

warn_about_external_useFunction · 0.90
EmailMessageClass · 0.90
get_connectionFunction · 0.70
send_messagesMethod · 0.45