MCPcopy
hub / github.com/django/django / send

Method send

django/core/mail/message.py:376–411  ·  view source on GitHub ↗

Send the email message.

(self, fail_silently=False, *, using=None)

Source from the content-addressed store, hash-verified

374 return [email for email in (self.to + self.cc + self.bcc) if email]
375
376 def send(self, fail_silently=False, *, using=None):
377 """Send the email message."""
378 if not self.recipients():
379 # Don't bother creating the network connection if there's nobody to
380 # send to.
381 return 0
382
383 # RemovedInDjango70Warning: replace the remainder of this method with:
384 # from django.core.mail import mailers
385 # mailer = mailers.default if using is None else mailers[using]
386 # return mailer.send_messages([self])
387
388 from django.core import mail
389
390 if fail_silently:
391 warn_about_external_use(FAIL_SILENTLY_ARG_WARNING, RemovedInDjango70Warning)
392 if hasattr(self, "get_connection"):
393 raise AttributeError(
394 "EmailMessage no longer supports the undocumented "
395 "get_connection() method."
396 )
397
398 if using is not None:
399 report_using_incompatibility(self._connection, fail_silently)
400 connection = mail.mailers[using]
401 elif self._connection:
402 connection = self._connection
403 if fail_silently:
404 raise TypeError(
405 "fail_silently cannot be used with a connection. "
406 "Pass fail_silently to get_connection() instead."
407 )
408 else:
409 connection = mail.get_connection(fail_silently=fail_silently)
410
411 return connection.send_messages([self])
412
413 def attach(self, filename=None, content=None, mimetype=None):
414 """

Callers 15

test_long_linesMethod · 0.95
test_idn_addressesMethod · 0.95
test_lazy_addressesMethod · 0.95
test_sendMethod · 0.95
test_send_usingMethod · 0.95
send_mailMethod · 0.45
authenticateFunction · 0.45
loginFunction · 0.45

Calls 5

recipientsMethod · 0.95
warn_about_external_useFunction · 0.90
get_connectionMethod · 0.45
send_messagesMethod · 0.45