Comments (5)
Hi Maxcell,
Concurrency is so very first class in Elixir and it is as easy as Task.start(MyEmailModule, :send_welcome_email, [arg1, arg2])
to asynchronously send an email. Many libs of different uses provide their async strategy, which can be useful, but it can often be very repetitive and useless to have a built in way of "doing it asynchronously" in Elixir libs if you already have developed a universal / business-specific way of doing it. That is my thought. I'm not sure if @stevedomin ever thought about adding a builtin approach to it.
Additionally, email-sending functionality can be very business logic oriented. Do you want to retry? How do you want to handle async errors? Those are the questions that you may get different answers from different users of the lib. It's hard to satisfy every user.
Po
from swoosh.
hello @maxcell, very good question!
As @princemaple said it would be very easy to start using Task
to send emails in your project. The reason why this convenience was deliberately not added to this project is that I want users to make the decision about the tradeoffs involved with doing it this way.
Many people coming to Elixir, Phoenix and presumably Swoosh come from the Rails world and the deliver_later
function has a special semantic attached to it, it usually means that the email delivery will be done using ActiveJob to provide asynchronous execution. That also means you can easily see if it has failed, it can be retried, etc.
It wouldn't be the case with Task
, or at least not with a naive Task
implementation, and that's why I've been reluctant to add it to Swoosh.
However it would probably be worth adding a section to the README and the docs explaining this reasoning.
I'm also very open to revisiting this question, at least maybe we can add a Behaviour that would have to be implemented by various backends to provide the deliver_later
functionality. What do you think?
from swoosh.
Now we have a section in README about async! https://github.com/swoosh/swoosh#async-emails
from swoosh.
Thank you by the way @princemaple
from swoosh.
@maxcell not a problem at all :)
from swoosh.
Related Issues (20)
- Add OhMySMTP adapter HOT 2
- Option to set default sender for all the mails. HOT 2
- Allow using custom CIDs for inline attachments HOT 6
- Swoosh.Adapters.Test is not working with Wallaby HOT 3
- Attachments show as "noname" HOT 5
- Update OhMySmtp to MailPace (rename) HOT 8
- Mailinator: Attachment removed HOT 8
- Support for ExAws credentials in SES adapter? HOT 7
- Warning when compiling swoosh (ExAws.Config.new/1 is undefined) HOT 4
- weird html_body formatting when using assert_email_sent HOT 6
- How to add custom header to an email? HOT 1
- Add headers support in assert_email_sent HOT 1
- Support ics in alternative HOT 9
- send email in background, but in a simple way HOT 3
- Crashes caused by the Memory GenServer
- Terminate/cancel the currently sending email HOT 7
- Mailjet Adapter deliver_many return type is inconsistent HOT 10
- SMTP: Authenticity is not established by certificate path validation HOT 12
- Multiple reply_to addresses (Sendgrid) HOT 3
- Documentation for Swoosh.Adapters.SMTP inadeqete HOT 1
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 swoosh.