You may have noticed, that when using standard PHP mail send functions, you cannot use your own domain as the sender address.
The reason for this is, that Domain ownership / management is in no way tied to our system. Without a way to properly validate domain ownership internally, we cannot guarantee that a website would only be able to send mail via the allowed domains. Effectively, any website could claim to send mail via any domain, which is obviously no good.
Mailgun is a nifty little service to solve this issue. Here’s how to set it up:
- Install “Mailgun for WordPress” -plugin for your WordPress site. You can either search for it in WP Admin, or find it here: https://wordpress.org/plugins/mailgun.
- Create a free account at https://mailgun.com and choose to add your Credit Card. Without a Credit Card added, all recipient addresses have to be added in manually! You will not be billed for basic usage (10 000 emails per month).
- Add your domain using mailgun.com dashboard. Mailgun will then instruct you on how to validate your domain.
- After adding the domain, find the “API Key” Mailgun generated for your domain under “Domain Information”.
- Copy the “API Key” and add it to your “Mailgun for WordPress” -plugin settings.
- Also set “From Name”, “From Address” and “Mailgun Domain Name” at plugin settings.
And presto! Your outgoing email will now be sent through the domain you specified.