-
Notifications
You must be signed in to change notification settings - Fork 135
Issue Batch Sending to GSuite Email Aliases #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
So, this sounds really weird. There's no way for Anymail to know anything about G Suite aliasing—as far as Anymail's concerned, [email protected] and [email protected] are completely different email addresses, and Anymail will ask SendGrid to send to both of them. And actually, there's no way for SendGrid to know about G Suite aliasing either. They should be sending a message to each different address, as asked. So checking your SendGrid activity feed was a great place to start:
This is suspicious. I'd suggest looking at these, in order:
[You might be tempted to also look at SendGrid's "opened" events, but these can be misleading because of the way Gmail proxies tracking pixels and other images.] It's unlikely sending each message separately, rather than batch send, would make a difference. But if you have a reproducible test case, it certainly can't hurt to compare. (Unless you're batching hundreds of emails at once, the performance probably won't be noticeably different.) |
@medmunds, thanks for getting back to me so quickly. 1 / 2. I think I may have made a premature comment on messages not showing up on SendGrid. SendGrid activity seems to lag and so in hindsight, all messages to I have had issues with opens and clicks in G Suite in the past. Historically, we've seen and overestimation of clicks and opens however now I'm seeing no opens or clicks. This might also be a function of the dummy template I'm using to test this. Sorry about that but I appreciate the helpful information.
In the meantime, for anyone else having difficulties, I was able to do this to make this work by approaching in a slightly different way. Haven't run performance metrics yet but I don't think there's much of a hit as I'm only using one connection and executing the send method once. from django.core import mail
from django.core.mail import EmailMessage
to_emails = ["[email protected]", "[email protected]"]
data = {
"[email protected]": {"some_var": "Hello0"},
"[email protected]": {"some_var": "Hello1"},
}
connection = mail.get_connection()
messages = []
for t in to_emails:
d = {}
d[t] = data.get(t)
message = EmailMessage(to=[t])
message.template_id = "d-585141a716834e60b9bb2a599215c1c4"
message.merge_data = d.copy()
messages.append(message)
num_sent = connection.send_messages(messages)
connection.close() I'll close this issue, thanks again for your help. |
I'm having issues batch sending in a very specific case where two of the emails belong to the same user, specifically when they are alias's of the same user through G Suite.
I'll put in dummy domains to highlight the example. Assume I owned test.com and test2.com. I may have both of these emails configured in the same G Suite account such that I can send and receive from [email protected] and [email protected] by logging into gmail from [email protected].
In this scenario, I may want to send a batch email using anymail and SendGrid via the following:
message.send()
returns 1, as expected. However, only one message gets delivered. Looking at my SendGrid dashboard, I sometimes see activity showing both messages, sometimes just one.The use case here is for a monthly status update email for a set of users. It is possible that users will have multiple accounts using emails that use different domains but are actually aliased to the same G Suite (or other email provider) user.
While this may be a rare case, without a resolution, I was going to follow the Django guide on sending multiple emails instead of the Anymail batch send. Is there an alternative recommendation for best practices when using Anymail?
I'm suspicious this may be a G Suite or SendGrid but was hoping for feedback on if this could be an Anymail issue. If it's a limitation of Anymail I'd be happy to help contribute either to the docs or codebase to resolve the issue.
Appreciate the help!
The text was updated successfully, but these errors were encountered: