Skip to content
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

Impossible to use send from short-lived processes #348

Open
brigadier opened this issue Jan 20, 2025 · 2 comments
Open

Impossible to use send from short-lived processes #348

brigadier opened this issue Jan 20, 2025 · 2 comments

Comments

@brigadier
Copy link

brigadier commented Jan 20, 2025

It is impossible to use asynchronous send from short-lived processes,

The send method calls start_link, so when it gets called from a short-living process such as for example cowboy handler the smtp sending process terminates prematurely just after parent process terminates.

I mean it is possible but one has to spawn a process just to be able to to call send

@mworrell
Copy link
Collaborator

This is by design. You can indeed do a spawn and call the synchronous method. That will make you responsible for managing the spawned process. Or just send the mail synchronously from your main process, then you can also handle the result.

If you are sending you will also need to handle the retries and other logic. Regretfully, sending mail isn't just "send and forget", unless you are using a relay and are absolutely sure that the relay is 100% up and reachable.

@brigadier
Copy link
Author

But there's the third parameter of send, a callback fun which I think exists exactly for handling return values out of the caller process, right? And the only way to react on errors without callback is to set trap_exit for the caller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants