Receive Emails on Server for Processing

software development



I’d like my server to process the text content of emails received on a certain email address, preferably using PHP. The email address is hosted by DH and I have a dedicated DH server so no problem setting up cronjobs etc.

Emails received will be about 100 per day. I need access to the title text and content.

Could someone please suggest how to approach this. I know PHP but not done this before. Thank you.



Basically you need to forward the email twice. The first time from dreamhost mail system to the webserver. Then on the webserver forward the email to a pipe.

For the first step log into the dreamhost panel and choose Mail > Message Filters. Click edit next to the email account that will be receiving the email, on the next screen add new filter. You want the option to “Forward to a Shell account”, and the possible options should be presented for you in a dropdown list. Your dedicated server user should appear in the drop down list.

Note: to forward “ALL” in the above step, the simplest way is to use reverse logic with a garbage string i.e. "Subject does NOT contain “dklfjdkfjdfkjdkjf”

Now the email will be forwarded from dreamhost’s mail servers to your webserver’s user, once it’s there we need to forward to a script on the webserver using a pipe. See this wiki article for examples:

no cron needed.


Hi LakeRat,

That’s superb! Many thanks for posting all that information. Very much appreciated and that is ideal.