LaunchPadQuick 🚀
To enable magic link authentication in your Next.js 14 SaaS application using Mailgun, you'll need to obtain your Mailgun API keys. This guide will walk you through the process of signing up for Mailgun and retrieving the necessary API keys, using the free sandbox domain that Mailgun provides.
Visit Mailgun's website and sign up for an account. You can start with a free trial which includes a generous number of free emails per month.
Once logged in, navigate to 'Sending' > 'Domain', then click on the provided domain, from there you should click on the 'SMTP' for setting up magic link.
With your API keys in hand, update the .env file in your Next.js project. Ensure the following environment variables are set:
1
2
3
4
EMAIL_SERVER_HOST="paste the email host here"
EMAIL_SERVER_PORT="paste port here"
EMAIL_SERVER_PASSWORD="paste password here"
EMAIL_FROM="you can type your example email address here like 123@mydomain.com"