I'm doing this on one of my sites email's (on ISPconfig 2) You will need to add the following in /etc/aliases web96_info: "|/var/www/web96/web/script.php" After this run newaliases to re-create the aliases db. Now all email going to web96_info will be "piped" to /var/www/web96/web/script.php More info here: http://www.evolt.org/article/Incoming_Mail_and_PHP/18/27914
so, if i had 2 email addresses in the server such: [email protected] and [email protected] one alias such as support will handle theses 2 adresses?? could we get only ONE of thies email??
Sorry.. My misstake. It will only work for one domain. So if you need it for two you will need to set it up for both domains. web96_support: "|/var/www/web96/web/script.php" web97_support: "|/var/www/web96/web/script.php" web96_support is for [email protected] and web97_support is for domain [email protected] (you will need to change the web96 and web97 to your own number) You can point both to the same script.php
OK, I understand, so webX is the internal ID of ISPCONFIG fort each domain... I'm doing it but i have errors: email to parse: [email protected] the email accoutn is not created in ispconfig in /etc/aliases I have added: web4_support: "|/var/www/clients/client0/web1/web/cli/index.php" web4 because i see in /var/www/clients/client1: hardjob.com -> /var/www/clients/client1/web4/ but when i send an email to [email protected] it returns it and i see in /var/log/mailog: Recipient address rejected: User unknown in virtual mailbox table PD: hardjob.com is not my domain
yes, i have run newaliases to recreate them. i have not catchall, iu have created now, but it doesn't work, the email is redirected to other email address but the pipe doesn't work...
It could be a permission problem! I have this running on a ISPconfig 2 server (on: ). Tomorrow I will test all this on my ISPconfig3 server. I'll report back as soon as I know more.
Can you also test: [email protected]: "|/var/www/clients/client0/web1/web/cli/index.php" or [email protected], "|/var/www/clients/client0/web1/web/cli/index.php"
Found it I think. Try: hardjob.com: "|/var/www/clients/client0/web1/web/cli/index.php" and than newaliases Let me know if it worked for you.
I've done some more testing on my ISPconfig 3 server, and I can for some reason not get it to work. Let me know if you find a way to make it work. Again.. Its working great on a ISP2config setup server.
How I got this to work... Since ISPConfig3 wants me to have a domain name with the email addresses I added a mail forwarding entry of "[email protected]" forwarded to script. In "/etc/aliases" I added "script: |/var/www/some_directory/email_script.php". Then run "newaliases". Note that the directory is not in a web root of any client. "email_script.php" contains... Code: #!/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; } } preg_match("/boundary=\".*?\"/i", $headers, $boundary); $boundaryfulltext = $boundary[0]; if ($boundaryfulltext!="") { $find = array("/boundary=\"/i", "/\"/i"); $boundarytext = preg_replace($find, "", $boundaryfulltext); $splitmessage = explode("--" . $boundarytext, $message); $fullmessage = ltrim($splitmessage[1]); preg_match('/\n\n(.*)/is', $fullmessage, $splitmore); if (substr(ltrim($splitmore[0]), 0, 2)=="--") { $actualmessage = $splitmore[0]; } else { $actualmessage = ltrim($splitmore[0]); } } else { $actualmessage = ltrim($message); } $clean = array("/\n--.*/is", "/=3D\n.*/s"); $message = trim(preg_replace($clean, "", $actualmessage)); // Everything after here is just for testing... $from="From: ".$from."\n\n\n"; $subject="Subject: ".$subject."\n\n\n"; $message="Message: ".$message."\n\n\n"; $headers="Headers: ".$headers."\n\n\n"; $email=$from.$subject.$message.$headers; mail('[email protected]','Script Response', $email); // Directory must be 777 to write to it... $myFile = "/var/www/some_directory/email_script_test.txt"; $fh = fopen($myFile, 'w'); fwrite($fh, $email); fclose($fh); ?>
We got it all working. Have a look here: http://www.howtoforge.com/forums/showthread.php?t=42755 You only need to add some stuff to the "Custom Rules > Custom mail filter recipe" still thank you for posting the info.