I have a server with a static IP and also a domain pointing to it. Because it is behind a firewall that blocks SMTP (ingoing and outgoing), I am not able to send any EMail from it.
To be able to send and receive EMail with the domain anyways, I use Mailgun.
I can send EMail with GMail, for example - but not with PHP, since I have only found instructions to configure sendmail() using SMTP. Fortunately, Mailgun offers a HTTPS API to send EMail.
The question
How can I configure PHP to call a script on my server, which itself calls the Mailgun API?
Note: calling the API is not the issue. I only need help configuring PHP.
What I have tried
In the php.ini, you can set the path to the sendmail binary like this:
sendmail_path = /path/to/sendmail
I pointed this to a script which just dumps all params into a file:
echo "$@" > /path/to/output.txt
The script indeed gets called whenever mail()
in PHP is called, but apparently there is a problem with the parameters. When I cat output.txt
, I only get two empty lines.