schilly Posted May 5, 2009 Share Posted May 5, 2009 Is there a way to process incoming email to the mail server and pass it off to php for processing? I am looking to set up a support ticket system. the biggest shortfall right now is how to process the replies from the clients. any help or ideas is greatly appreciated. thx. Quote Link to comment Share on other sites More sharing options...
schilly Posted May 5, 2009 Author Share Posted May 5, 2009 found a decent tutorial. hopefully this works http://www.evolt.org/article/Incoming_Mail_and_PHP/18/27914/index.html Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 5, 2009 Share Posted May 5, 2009 I use a that script (or a script that started out as that script) to process email. It works very well. Ken Quote Link to comment Share on other sites More sharing options...
schilly Posted May 5, 2009 Author Share Posted May 5, 2009 awesome. thanks Ken. script looks straight forward. just hope i can do all the sendmail alias setup properly. Quote Link to comment Share on other sites More sharing options...
StefanRSA Posted May 5, 2009 Share Posted May 5, 2009 It is called "pipe email to php script" It is not a very well known way of doing things, and not even google could help me with that. I am fairly new to php and found my answer looking at the open source "eticket" system and how they do it... If you use their pipe to email script will you save yourself a lot of trouble... Let me know if you need more help! Stefan Quote Link to comment Share on other sites More sharing options...
schilly Posted May 5, 2009 Author Share Posted May 5, 2009 you used eticket or just grabbed their script? having problems right now trying to reload the aliases. i can't find newaliases for some reason. Quote Link to comment Share on other sites More sharing options...
StefanRSA Posted May 5, 2009 Share Posted May 5, 2009 Do you have a dedicated server? I grabbed their script installed the system and modified the pipe script they r using. I must warn you! This is not an easy task to tackle!!! Best is to download the eticket system, install it and see how they parse the email.... I bet this will be your easiest way in winning this task! Quote Link to comment Share on other sites More sharing options...
schilly Posted May 5, 2009 Author Share Posted May 5, 2009 any ideas on finding newaliases? Quote Link to comment Share on other sites More sharing options...
StefanRSA Posted May 5, 2009 Share Posted May 5, 2009 If you are lucky enough to have CPanel on your server account you can create a new email where the script will be mailed to and create a "Email Account Forwarders" for that email account. The forwarder look something like this: Address Forward To pipemail@domain.com |/home/thehost/public_html/online/ticket/pipe.php Forget about what ever you found on google about pipe email to php script as I have found NO solution that work! What do you want to use this script for? Quote Link to comment Share on other sites More sharing options...
schilly Posted May 5, 2009 Author Share Posted May 5, 2009 it's going to be used for a ticket system. ok i finally got it working. for anyone using qmail, this is how i did it -create new mailbox in plesk/web interface -log in through shell -open /var/qmail/mailnames/domain.com/mailbox_username/.qmail -add | /full/path/to/script/script.php on a new line restart qmail: /etc/init.d/qmail restart make sure script file is 755 perms (chmod if needed) email will be delivered to the mailbox as well as the script php script: #!/usr/bin/php <?php // read from stdin $fd = fopen("php://stdin", "r"); $email = ""; while (!feof($fd)) { $email .= fread($fd, 1024); } fclose($fd); // handle email $lines = explode("\n", $email); // empty vars $from = ""; $subject = ""; $headers = ""; $message = ""; $splittingheaders = true; for ($i=0; $i < count($lines); $i++) { if ($splittingheaders) { // this is a header $headers .= $lines[$i]."\n"; // look out for special headers if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) { $subject = $matches[1]; } if (preg_match("/^From: (.*)/", $lines[$i], $matches)) { $from = $matches[1]; } } else { // not a header, but message $message .= $lines[$i]."\n"; } if (trim($lines[$i])=="") { // empty line, header section has ended $splittingheaders = false; } } //test email to make sure it works mail('email@domain.com',"Testing Email Piping","Headers: $headers\n\n\n Message: $message"); ?> do not send the test email to the same account. i should have known better. infinite loop. 1000 emails in the span of a few mins. as Stefan said it can probably be done through your web interface as well but I didn't have access to it so had to go through shell. hope this helps anyone else looking to do this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.