Basic example using Mailgun and PHP to submit a contact form.
- Rename
.env.example
to.env
and add your personal settings. - Start a PHP server and set
public/
as your root directory. - Load the page, submit the form, and check your email.
Form:
Email:
To keep your API keys secret:
- Make the Mailgun request server-side (e.g., with a PHP script)
- Add your keys to a
.env
file - Add
.env
to your.gitignore
To find your API key:
- Login to Mailgun
- Add a new domain
- Copy your API key