MCPcopy
hub / github.com/django/django / send_messages

Method send_messages

django/core/mail/backends/smtp.py:165–187  ·  view source on GitHub ↗

Send one or more EmailMessage objects and return the number of email messages sent.

(self, email_messages)

Source from the content-addressed store, hash-verified

163 self.connection = None
164
165 def send_messages(self, email_messages):
166 """
167 Send one or more EmailMessage objects and return the number of email
168 messages sent.
169 """
170 if not email_messages:
171 return 0
172 with self._lock:
173 new_conn_created = self.open()
174 if not self.connection or new_conn_created is None:
175 # We failed silently on open().
176 # Trying to send would be pointless.
177 return 0
178 num_sent = 0
179 try:
180 for message in email_messages:
181 sent = self._send(message)
182 if sent:
183 num_sent += 1
184 finally:
185 if new_conn_created:
186 self.close()
187 return num_sent
188
189 def _send(self, email_message):
190 """A helper method that does the actual sending."""

Callers 2

send_mass_mailFunction · 0.45
sendMethod · 0.45

Calls 3

openMethod · 0.95
_sendMethod · 0.95
closeMethod · 0.95

Tested by

no test coverage detected