Help with Email Piping


#1

I need to understand how to pipe email with Dreamhost.

I haven’t get to the part where I actually do this yet, because I feel like I am missing something here.

  • I understand that I need to create a user with shell access.
  • I understand that I need to create an email address
  • I understand that I need to create Message Filter to forward email to the shell user

Now, let say I have pipe.php… where/when do I set that pipe.php will receive these emails?

Oh, by the way, I assume that I can also use this with catch-all email, right? I have the need to use that, and depending on who the email is sent to (To:), pipe.php will process it accordingly.


#2

I don’t know of any easy way to grab the event “new mail rec’d” and cause it to trigger a php script.

You could set a cron to run the php say every hour (or more frequently, but be mindful not to be wasteful and a hog of server resources). The script could look in /home/username/Maildir/new/ and if there is no new mail then it would exit, if there is new mail then it processes it.

I did something like this a few years ago when I first got an iPhone. I set up an email to receive pics. The attachment was stripped out of the email and moved to a specific folder that displayed it as the “pic of the moment” on a webpage.

I see no reason it couldn’t be done with a catch-all but remember if your doing something like i did above to have some reasonable means to identify email that doesn’t apply and discard it. In the example above I used 2 ‘keys’ to make sure someone didn’t just start spamming pics to the email i set up.


#3

aaah… I think I got it now. When I set the Message Filter to send the email message to a shell user, it actually creates the email as a file to some folder. Is that right? If that is the case, I understand why the need for cron. Because when I did email piping last time, on a different host, I pipe it to a script, and the script gets triggered everytime a new email arrives.

Just wondering if that can be done here with Dreamhost, with normal shared hosting, not VPS. If not, then I guess my only option is to use cron.


#4

I knew how *nix mail worked long ago, so just seemed like a natural to look in /home/username/Maildir/new/ and exit if it was empty.

I have no idea how to pipe new mail rec’d by the shell to a php script. How was it done at the other host? that will give us a place to experiment.


#5

The standard way to pipe email directly to a script (rather than sending it to a maildir for pickup later) is using .forward files. Create a file named “.forward” in the home directory of the shell user that will be receiving the mail, with contents like:

This will pass the contents of any received email to that script.


#6

Awsome!! I will remember! I didn’t know you could use a .forward in that way.