How to do an email check/confirmation/validation with Phoenix?

For the record, here’s how I’ve done it.

To send emails, I used the mailgun package. The setup is described in the phoenix docs section “Sending Email with Mailgun

To add the confirmation logic, I started a new phoenix application with phauxth (with mix --confirm), which is the openmaize library for Phoenix 1.3, just to see the code and to test it. Then I installed the phauxth package to my ongoing project and replicated the code needed just for the confirmation flow.

Thank you all for all the help!

I’d do it the same way as Bobby :023:

I would also include the user-id in the params, and retrieve the record based on that (then check the verify token to confirm or deny) as usually the user_id field will be indexed (resulting in much faster retrieval).


Dockyard (@alexgaribay :tada:) has recently published a guide on how to do email verification. It’s similar to the basic flow I stated above, but with leveraging Phoenix.Token as a unique token generator and expiry checking, making it unnecessary to store the token in the DB. I think that’s a really neat and lean approach!


A post was split to a new topic: Adding an Email Verification Flow With Phoenix

constructs a verify link with the token and send it to the user (might also want to include the user ID in it)

Are there any tutorials on how to constructs a verify link?

Here I was trying to constructs one, but still can’t figure out completely yet.

Hi @sawthinkar, the DockYard tutorial article that I shared just above your post outlines how the typical email verification with Phoenix goes (including verify link generation). There’s also a thread about it in this forum:

Do you have any problems in following them?

1 Like

I got a bit confused on Path Helpers. I was trying to construct the link in html.eex file. It wasn’t properly setup so was getting endpoint errors. I got it now. Thanks! :grin:

Email checkers would be fine for the beginners.

1 Like