sendgrid-python: Batch sending of emails not working
Hello,
I’m testing my code for the latest version of the library. When I send emails one at a time (one per API call), it works fine. When I send multiple emails in an API call, only one of the emails is received.
Below is an excerpt of JSON sent for a batch of 10 emails (minimally edited to remove personal info). I’m sending to my personal gmail account using the + notation, e.g., recipient+0@gmail.com through recipient+9@gmail.com.
One extra weirdness is that the Sendgrid email activity log says that all 10 emails are delivered even though they are not. I find it very strange that this works sending individually (to all 10 email addresses) but not in batches of 10 at once.
I’d greatly appreciate any help you can provide.
Jeff
{'categories': ['begin'],
'custom_args': {'eid': '5715143556071424'},
'from': {'email': 'noreply@example.com'},
'personalizations': [{'custom_args': {'vkey': 'aglzfm'},
'send_at': 1486243132,
'substitutions': {'{{description}}': u'<p>xgfddfdfhdf</p>',
'{{item_title}}': u'Best Cat',
'{{manager_email}}': u'manager@example.com',
'{{manager_name}}': u"Jeff O'Neill",
'{{unsubscribe_link}}': u'https://www.example.com/remove/',
'{{vote_link}}': u'https://www.example.com/vote/'},
'to': [{'email': u'recipient+0@gmail.com'}]},
[...]
{'custom_args': {'vkey': 'aglzfm'},
'send_at': 1486243141,
'substitutions': {'{{description}}': u'<p>xgfddfdfhdf</p>',
'{{item_title}}': u'Best Cat',
'{{manager_email}}': u'manager@example.com',
'{{manager_name}}': u"Jeff O'Neill",
'{{unsubscribe_link}}': u'https://www.example.com/remove/',
'{{vote_link}}': u'https://www.example.com/vote/'},
'to': [{'email': u'recipient+9@gmail.com'}]}],
'reply_to': {'email': u'manager@example.com'},
'subject': u'Best Cat',
'template_id': '6060c6e9-0376-4b52-ac15-e6befd906072'}
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 17 (9 by maintainers)
Hi Vivek,
My solution was to append a short text slug of random characters to the end of each subject using the Python snippet below. Google will deliver all the emails if the subjects are unique.
This is not an ideal solution, but it works for now. I may switch to another provider at some point if Sendgrid doesn’t provide a better fix.
Jeff
I’ll follow up with support.
Your example also worked for me, but if you change the emails to all have the same subject then only one is delivered.
Jeff O’Neill | Founder and Director jeff.oneill@opavote.com
On Wed, Feb 8, 2017 at 2:03 PM, Elmer Thomas notifications@github.com wrote: