Skip to content

reuse SMTP connections

Bengfort requested to merge mail-connection into main

Django provides two high-level functions to send mails: send_mail() and send_mass_mail(). The latter one uses a single SMTP connection for a whole bunch of messages, but it does not tell us which messages were sent successfully. So until now we use send_mail() and therefore a fresh connection for every message, which causes some trouble.

Using some lower-level functionality it is possible to get both: A single connection and still know which messages were sent successfully. My main issue is about how to put this into an elegant API considering also the "context" concept we have for mails. The current approach is somewhat useful, but I hope I can improve it a little bit more.

Edited by Bengfort

Merge request reports