Email to php pipe help

software development

#1

I’m trying to forward email to a PHP script using a pipe. I want the PHP script to read the email and store the messages in a text file.

I read a bunch of forum posts here and tried following DreamHost’s wiki. Here’s what I got so far:

In my root directory, I have a .forward.postfix file with 1 line:

“|/usr/bin/procmail”

Also in my root directory, I have a .procmailrc file, with some code:

DEFAULT=$HOME/Maildir/
MAILDIR=$HOME/Maildir
PMDIR=$HOME/.procmail
LOGFILE=$PMDIR/log
SHELL=/bin/sh
LD_LIBRARY_PATH=/usr/local/php5/lib/php
PHP=/usr/local/php5/lib/php

:0

  • ^TO_myemail@mysite.net
    |$PHP -q /home/myusername/mysite.net/log.php

I tried sending an email to myemail@mysite.net, but log.php didn’t write anything in the log.txt file. :frowning:

So my question is: What do I do now?

Does the .procmailrc file have an error? I don’t think my log.php has an error, but I will post the code if anyone wants to see it.


#2

I would try leaving out the php stuff and just have it forward to your email address first… once you know that works then try the script…

You might want to use “|/usr/bin/procmail -t” in your .forward.postfix instead…

chmod 600 .forward.postfix & .procmailrc


#3

i followed what this guy did:
http://discussion.dreamhost.com/showthreaded.pl?Cat=&Board=forum_programming&Number=12021&page=&view=&sb=&o=&vc=1#Post12021

now my .forward.postfix has this code:

“|/usr/bin/procmail -t”

my .procmailrc has this:

DEFAULT=$HOME/Maildir/
MAILDIR=$HOME/Maildir
PMDIR=$HOME/.procmail
SHELL=/bin/sh
VERBOSE=yes
LOGFILE=$PMDIR/log
LD_LIBRARY_PATH=$HOME/email/php
PHP=$HOME/email/php/php

:0

  • ^TO_myemail@mysite.net
    .junk/

My email isn’t getting forwarded to the junk folder. :frowning:

What’s wrong with my .procmailrc?


#4

I really really want to get this email to PHP pipe to work!!

I followed what this guy said:
http://discussion.dreamhost.com/showthreaded.pl?Cat=&Board=forum_programming&Number=12021&page=&view=&sb=&o=&vc=1#Post12021

My .forward.postfix has:

“|/usr/bin/procmail -t”

My .procmailrc has:

DEFAULT=$HOME/Maildir/
MAILDIR=$HOME/Maildir
PMDIR=$HOME/.procmail
SHELL=/bin/sh
VERBOSE=yes
LOGFILE=$PMDIR/log
LD_LIBRARY_PATH=$HOME/email/php
PHP=$HOME/email/php/php

:0

  • ^From:.*(gmail.com)
    |$PHP -q $HOME/email/recieve.php

I tried using myaccount@gmail.com to send an email to myaccount@mysite.com to test it, but my PHP script doesn’t do anything, and the email doesn’t arrive in the inbox.

When I delete the .forward.postfix file from my site, and I send another email to myaccount@mysite.com, it arrives in the inbox.

So… what’s wrong… is the .forward.postfix forwarding to the wrong place or something? :’(


#5

I’m still trying to get the email to PHP pipe thing to work. :frowning:

help anyone???


#6

I won’t be able to help you directly, but it looks like:

  • without the procmail file, mail gets to your inbox
  • with the procmail file, the mail does not go where you want it to
  • with the procmail file, it does not go to you inbox
  • you defined a log file, and have a verbose setting

Is there anything in your log file?


#7

This is not the problem, yet anyway, but I could not get procmail to pipe to a php script. I had to use a cgi script. So beware, once you have procmail working, if you can’t get it to pipe to your php script, you might try a cgi script