LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Piping mail to php... (Solution, and a wee note for Donncha)

[ILUG] Piping mail to php... (Solution, and a wee note for Donncha)

adam beecher adam at iewebs.com
Sat Apr 15 01:05:46 IST 2000


For any PHP hackers who're interested, I figured out a somewhat kludgy
solution. Having searched all bloody night I came across this thread, which
correlates closest to my dilemma:

http://marc.theaimsgroup.com/?t=91567522400001

The problem in that thread was the exact same as mine - you can pipe
something in from the command line, but it just won't work with a sendmail
alias for some reason. And as far as I'm concerned, if Rasmus can't figure
it out, better to let it lie. :)

The only way around it was to create a shell script to read the data from
STDIN and then pipe THAT to the PHP script. This is just a simple example
that resends the mail, headers an' all:

----------------------------------------------------------------------

SHELL SCRIPT

#!/path/to/sh
cat |/path/to/php/script

----------------------------------------------------------------------

PHP SCRIPT

#!/path/to/php -q
<?
$fp = @fopen("/dev/stdin", "r");
	while (!feof($fp)) {
		$rawdata .= fgets($fp, 4096);
	}
fclose($fp);
mail ("user at sld.tld", "Subject", $rawdata);
?>

----------------------------------------------------------------------

Then set up an alias for it:

user: |/path/to/shell/script

And if you're running smrsh (like me apparently :), you'll
need to create a link to the shell script for sendmail:
(Maybe this is why I can't get at STDIN from PHP?)

ln -s /path/to/shell/script /path/to/smrsh

Now just rebuild the aliases file and you're done:

newaliases


That's it. I'm off back to my phorums installation now to play with it.

Tata,
adam

PS. Hey Donncha, couldn't you use this for IO? Pipe the data into PHP, parse
the headers, put the resultant data into MySQL and voila, a searchable list
archive (which I just happen to be working on meself :). Then you could
simply reference each email in the DB from the hierarchy of topics you've
already created. Searchable, threaded list archive and IO in one! And if you
want a real challenge, well, Majordomo & HyperNews are getting a bit boring
aren't they? And MARC is a bit dull looking too! :)

adam


_______________________________________________________
<?php
$s=array("&#74;","&#65;","&#112;","&#104;","&#112;","&#72;");
for($i=0;$i<count($s);$i++){echo$s[$i];}
?> :)





More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell