Question

How to Piping email to PHP Script in DigitalOcean

I need to pipe incoming emails to a specific address to a PHP script on DigitalOcean. I have done this on shared servers in Cpanel using a forwarder to |/opt/alt/php56/usr/bin/php -q /home/somesite/public_html/folder/somescript.php but I’m not sure how to set up something similar (if possible) on DigitalOcean VPS.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

In 15+ years working with PHP I’ve never had to use this particular feature. Doing some research, it seems that every reference to this I’ve found relies on this feature in cPanel rather than using lower level tools.

We generally recommend against running your own email services. They can quickly become a major time-sink and require more attention than most services to prevent abuse.

If you are writing the handler script yourself you have some other options. One alternative would be to create a CRON job that runs every few minutes and checks a POP or IMAP mailbox for new messages. This way there would be no piping and your script would simply pull new messages from the mail server you are using.

Another option would be to use cPanel on your server in order to take advantage of this feature in the same way you did previously. We don’t offer cPanel licenses but you can purchase a VPS license from cpanel.net or a reseller and install it on your droplet. cPanel/WHM features it’s own installer that makes the initial setup quite easy.