Re: E-mail Gateway

From: Date: Tue, 18 Nov 2003 09:37:46 +0000
Subject: Re: E-mail Gateway
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-170072@lists.php.net to get a copy of this message
> 2) Create a script where mail can be piped to. This is a method that I > have used previously with a cgi app called PerlDesk. In answer to Point 2... If you are in a position to edit your 'aliases file' you can feed email to a program using PHP quite easily. I am doing it and works quite well. So, 1st, edit your file (generally in /etc/mail/aliases) and add the line: testit: "|/usr/local/bin/php /path/to/your/php/file/processmail.php" (making sure this is the path to php etc) Below is an example how to capture the mail, the following simply reads the email into $buffer and emails it, this should hopefully point yu in the right direction... <?php define('STDIN',fopen("php://stdin","r")); $str = fgets(STDIN); $fp = popen('cat /dev/fd/0','r'); while(!feof($fp)) { $lines = fgets($fp,4096)."\n"; } $handle = STDIN; while (!feof ($handle)) { $buffer .= fgets($handle, 4096); echo $buffer; } fclose ($handle); mail("me@domain.com","Test","Test Test...\n\nOriginal Email:\n\n$buffer"); ?> - Brian M McGarvie - IT Manager (e-loanshop.com). - www.devdojo.com (Developer Community)

« previous php.general (#170072) next »