SparkPostCeleryEmailBackend for Django #108
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there!
Until recent times, I used Mandrill to send emails in Django projects. When I started migrating to Sparkpost I found there is no implemented way in python-sparkpost to send emails asynchronously using Celery. For example, I used
djrillcelerypypi package for it when I used Mandrill, and it worked well.I implemented this feature and there is my pull request. How you could use it:
Set up settings.py:
And now you can send email using usual way:
ris CeleryAsyncResultobject returned bysend_messagestaskr.resultis AsyncResult object for chord ofsend_messagetasksr.result.resultis integer number of successful emails returned bysend_summarytask, it will be non-zero when all tasks will be completed and whenr.result.successful()will be TrueYou can wait for final result, but in absolutely most cases I'm not waiting for results of email sending.
I installed my fork for one of my projects, and it works. I could not write tests for it, I don't know pytest.