I’m having trouble sending emails from my GoDaddy shared hosting server. The Mailgun WordPress plugin works fine, but I can’t get PHPMailer or php mail() to function.
My setup includes:
A WordPress site and a custom intranet on the same server
Mailgun as the mail server with properly configured MX and TXT records
An additional Office 365 email server with its own MX record
It appears that the Mailgun plugin uses HTTP instead of SMTP, and I want to replicate that in my PHP code. However, I’m not sure how to achieve this.
Below is a simplified example of what I think the plugin might be doing:
I’ve encountered similar challenges with shared hosting environments. One effective approach is to utilize Mailgun’s HTTP API directly, as you’ve outlined. However, to integrate this with PHPMailer, you’ll need to create a custom SMTP transport.
hey Tom, i’ve faced similar issues. have you tried using the mailgun php library instead of raw curl? it’s easier to work with. just install it via composer and use their official docs. also, make sure your api key is correct and you’re using the right domain. good luck!
This approach bypasses any server-level email restrictions and uses Mailgun’s API directly. It’s been rock-solid for me, even on budget shared hosting plans. Just make sure to keep your API key secure!