Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's not possible to directly use send_mass_mail() with EmailMultiAlternatives. However, according to <a href="https://docs.djangoproject.com/en/dev/topics/email/#the-emailmessage-class">the Django documentation</a>, send_mass_mail() is simply a wrapper that makes use of the <a href="https://docs.djangoproject.com/en/dev/topics/email/#django.core.mail.EmailMessage">EmailMessage</a> class. EmailMultiAlternatives is a subclass of EmailMessage. EmailMessage has a 'connection' parameter allowing you to specify a single connection to use when sending the message to all recipients - i.e. the same functionality as provided by send_mass_mail(). You can use the <a href="https://docs.djangoproject.com/en/dev/topics/email/#django.core.mail.get_connection">get_connection()</a> function to obtain an SMTP connection as defined by the <a href="https://docs.djangoproject.com/en/dev/topics/email/#smtp-backend">SMTP settings</a> in settings.py.</p> <p>I believe that the following (untested) code should work:</p> <pre><code>from django.core.mail import get_connection, EmailMultiAlternatives connection = get_connection() # uses SMTP server specified in settings.py connection.open() # If you don't open the connection manually, Django will automatically open, then tear down the connection in msg.send() html_content = render_to_string('newsletter.html', {'newsletter': n,}) text_content = "..." msg = EmailMultiAlternatives("subject", text_content, "from@bla", ["to@bla", "to2@bla", "to3@bla"], connection=connection) msg.attach_alternative(html_content, "text/html") msg.send() connection.close() # Cleanup </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload