Sending to multiple recipients
bentappin opened this issue · comments
Hello
At the moment (correct me if I'm wrong) it seems like we cannot send an email to multiple recipients with the same email. I assume the code is structured like this to support encryption.
Is there any room for modification of the library to support this?
Some thoughts on approaches ...
- Modifying
send_mail
to support both single and multiple recipient modes could be a bit messy and may also break users expectations. For example, you could not send to multiple recipients and supportUSE_GNUPG
. (Maybe an exception could be thrown?) - Adding a new multiple recipient send mail function could end up duplicating functionality in the existing
send_mail
function.
I'm happy to have a go and submit a PR if this is something that you want in the library.
Thanks for your time.
Ben.
Hi Ben,
This needs solving and a PR would be welcome. You're right that multiple recipients are currently sent separately to support encryption. As you've uncovered, this would probably be really surprising for the developer if they're not using encryption and specify 100 recipients while expecting only one email to be sent.
Perhaps we need to make the behaviour more explicit, and have it so that multiple recipients are sent to individually only when encryption is being used (USE_GNUPG
is True
), and they're all sent a single email when encryption isn't being used. We would then need an argument in send_mail
and send_mail_template
that can override the behaviour, so that even when encryption is being used, you can force a single mail send to multiple recipients, forgoing encryption. The name of the arg is probably the hardest part of the change - should it refer to disabling encryption, or forcing a single email to be sent? My feeling is the former, something like disable_encryption=True
. Then we just need to document the relationship between using encryption and sending single or multiple emails for multiple recipients.
Hmm didn't realise all this would appear here! Please see the PR rather than the fluff above.