Phoenix user activation email

Hi all,

I would like to activate this flow for the users of a Phoenix website (leveraging phx.gen.auth):

  • A user is automatically created without password by some script (DONE)
  • Send the activation email to the created user
  • When the user click the link in the email, the confirmed_at field is set and I can use that in the plug

I have a question:
In Django, the mailing system allow you to use the console as the adapter, so you can see the email in the console when in development, does swoosh have something similar?

Thank you
Cheers!

I believe I could use this during development:

https://hexdocs.pm/swoosh/Swoosh.html#module-mailbox-preview-in-the-browser

4 Likes

This works, yes.

I’ve also had success using this https://mailcatcher.me/ (more generic solution, not specific to elixir/phoenix).

Just to confirm, you’re familiar with the built-in /dev/mailbox route that is there by default, and you specifically want something in the console. Is that correct?

Correct.
/dev/mailbox is nice, console output would be awesome :slight_smile:

As a quick and dirty, why not create a wrapper around Mailer.deliver() that tests for mix environment if Mix.env == :dev do and logs or inspects the %Email{text_body: ""} to console? Then just use the wrapper in all your controllers.

Yeah, that’s an idea. Thank you!