Piping incoming email to php script


Several people have asked this in the past, and the best answers pointed to here:

However sadly, that content is gone.
If I email the shell username @forsyth.dreamhost.com it does show up in the Maildir. Great. Now how do I send it to my script?
Back in 2009 I did this successfully with a .forward.postfix.
I can’t get it to work now.

I did email DH support and they pointed me to the forums.

Surely there must be some way to do this.
I appreciate any help. I’ve been with DH for many many many years, hate to have to leave over this. You would think this would be well documented and supported. In the web panel they allow you to forward an email address to a shell user. I don’t know of any other reason you’d do that unless you were wanting to forward it to a script. So I really have to believe there must be a way. =D



The Internet Wayback Machine is great at finding things like this. Here is the link to the wiki page. https://web.archive.org/web/20150104160906/http://wiki.dreamhost.com/Email_to_Script


Well bless your heart! I tried the Wayback Machine but obviously didn’t go way back enough.
DH support did say “it appears that method is no longer supported, as this
option was removed a while back”, however I will try it anyway…

Thank you!


The method described on that page is what I did back in 2009 that worked. Still can’t get it to work.
I have in my .forward.postfix:
Permissions set to 755

First line of script.php is:

script.php does actually work when tested

Can anyone verify whether or not this method actually still works or not?
DH told me that anyone using it before was likely grandfathered in… but if they did it again it probably won’t work. Anyone done it recently?

I’m starting to lose hope.


Starting to lose hope as well!

I’ve scoured the corners of the internet trying to find a way. I only need to pipe 5-10 emails a day to the script but it’s really important I can do this.

It seems like it’s not possible as the Webserver and Email server are completely separate on DH but I’m also confused as to why it has an option to forward to a shell user and I’m holding out hope because of this.

Please dark lords of Dreamhosts… if it’s possible, please let us know!!


Thanks for your plea! I knew I couldn’t possibly be the only one in this boat! This seems like a very common function that people who do any development at all would want in a webhost.

It shows up in the Maildir in the shell user home directory. Fantastic… just can’t get it forwarded to my script.
.forward.postfix isn’t working, it used to work.
I wonder if the postfix thing is even installed now, I have no idea… or disabled by DH. I can’t fathom why they would disable this functionality.

Otherwise I’m looking at moving to another host, after 10+ years with DH. Any recommendations? Hostgator?
It appears that you can forward an email address to a script directly from cpanel. Why DH… why not you too!!! =D

I was thinking I could write a cron script that checked the Maildir at a frequent interval for new emails and processed them… however that should not be necessary. And even if I ran that script every 60 seconds it would cause extra delay.




So I gave up on this method last night. I found that php has an imap extension, so last night I wrote code to pull the email using the imap functions and got that working. The only problem is I’d have to do a cron job that runs every 60 seconds, which is far from ideal. Or a server daemon (always running script)…

Today I got an email from DH support, and they figured out the problem with my .forward!
I was pointing to the php library here (as I got from other threads regarding both cron and email piping):

Apparently that is no longer a valid path.

/usr/local/php55/bin/php points to a valid installation on their servers.

BINGO. That was it! Working now!!!

So my .forward now contains (with quotes, and username being your shell username of course):
"| /usr/local/php55/bin/php /home/username/test.php"
(where test.php is just sitting there in the home directory)

Thanks to Rob at DH customer support, a hero!

Hours of time lost, and all I needed was an extra 5. Go figure LOL.

I think they should update their documentation. Apparently not too many people are looking to do this.

Gregpm please confirm you saw this and it solves your problem. Otherwise I will try to help you fix it now that I know it is in fact still possible to do.