Comments (9)
Just to double-check: you've switched your code to use template_id
rather than template_name
(and merge_data
rather than merge_vars
), right?
(If you're migrating from Djrill, some of the Mandrill-specific attributes have been renamed in Anymail. The old Djrill attrs are still supported -- with deprecation warnings -- in Anymail's Mandrill backend, but not in the other ESP backends. Full list and a grep to help find them in the doc link above.)
If that's not the problem, it would be helpful to see the specific code that isn't working.
from django-anymail.
I didn't see any warnings in my console, but I'm setting the:
template_name
global_merge_vars
attributes of my EmailMessage object before sending. I'm using Django 1.8.
It's difficult to know what code isn't working, because there are no errors.
If I change template_name
to template_id
and also global_merge_vars
to merge_global_data
I do get an error:
Exception Type: AnymailAPIError
Exception Value:
Call to https://api.sparkpost.com/api/v1/transmissions returned 422, errors:
invalid combination of fields: Both content object and template_id are specified
Sending a message to xxx from xxx
ESP API response 422:
{
"errors": [
{
"message": "invalid combination of fields",
"code": "1301",
"description": "Both content object and template_id are specified"
}
]
}
Mandrill works fine with those changes.
from django-anymail.
OK, there are two problems here:
- Anymail has a bug with SparkPost stored templates leading to the 422 response you've listed above. I'm looking into that right now.
- Your code is using the old Djrill attribute names. You'll need to update them before switching from Mandrill to another Anymail ESP backend (like SparkPost). Please read through Anymail's docs on migrating from Djrill and change your code as needed.
To assist with migrating from Djrill to Anymail, Anymail issues DeprecationWarnings when you are using Anymail's Mandrill backend and use the Djrill names. (The new Anymail backends like SparkPost don't even bother looking for the old Djrill names. It's best to work through the migration docs before switching ESPs.)
Those warnings should show up in your dev server logs (and Django test output, if you have tests on email sending). If you'd like to change the warnings to errors to make them more visible see this StackOverflow answer.
Or you can run this git grep
command at the root of your project to find all instances of old Djrill names that need updating (from the migration docs):
git grep -w \
-e 'async' -e 'auto_html' -e 'auto_text' -e 'from_name' -e 'global_merge_vars' \
-e 'google_analytics_campaign' -e 'google_analytics_domains' -e 'important' \
-e 'inline_css' -e 'ip_pool' -e 'merge_language' -e 'merge_vars' \
-e 'preserve_recipients' -e 'recipient_metadata' -e 'return_path_domain' \
-e 'signing_domain' -e 'subaccount' -e 'template_content' -e 'template_name' \
-e 'tracking_domain' -e 'url_strip_qs' -e 'use_template_from' -e 'use_template_subject' \
-e 'view_content_link'
from django-anymail.
This stackoverflow question is also relevant. That's where I (and possibly anymail) am going wrong.
from django-anymail.
Ah - thanks -- that's exactly the problem. I'll have to figure out how to convince python-sparkpost not to put anything else in the content payload.
from django-anymail.
Pushing a fix momentarily. Until then, workaround is to explicitly specify subject=None, body=None
on your EmailMessage. (SparkPost is balking on the default empty strings for these fields.)
from django-anymail.
Many thanks @medmunds. The workaround has done the trick. Any chance of a new version number so that I can pip install on a server? No worries if not.
from django-anymail.
No problem -- thanks for catching it and identifying the cause.
New version will be 0.4.2. Just waiting for Travis-CI to approve, and then will push to PyPI.
from django-anymail.
Release 0.4.2 is live
from django-anymail.
Related Issues (20)
- Support Brevo inbound
- "Package would be ignored" warnings from setuptools when building package HOT 2
- Sendgrid multiple reply to HOT 1
- Can't lock with poetry HOT 2
- [Inbound] Apple Mail inline attachments not taken into account HOT 5
- Add support to Resend.com HOT 5
- Handlebars variables not substitued in mandrill templates HOT 1
- mailgun api key HOT 2
- Merging/Combine ESP Options get lost/overwritten HOT 2
- parse_address_list: Inability to Parse Email Addresses with Special Characters in Display Name Without Double-Quote Encapsulation HOT 1
- Mailjet Open tracking? HOT 4
- Inaccuracy in documentation about Brevo's behaviour HOT 2
- Feature request: Mailtrap HOT 4
- Resend: confusing ReadTimeout error for incorrect API key
- Add support to Unisender Go HOT 2
- Support Brevo batch sending with merge_data HOT 2
- Add batch sending support for Resend HOT 1
- Mailgun webhooks: AttributeError 'NoneType' object has no attribute 'get' HOT 1
- boto3 sesv2 client does not have method 'send_email'. Check AmazonSESV2SendEmailPayload HOT 4
- Bad UTF-8 "To" header encoding? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-anymail.