PHP script to pipe POP3 messages to STDout
Posted on 2003-11-20
I am trying to setup my site using FUDforum, and I want to figure out a way to handle mailing lists.
FUDforum has a script that takes stdin as a raw email message, parses it's headers and contents, and then throws it to the database as a new forum message. So far so good. Here's where I get stuck: The script depends on procmail for it's input, with procmail sending the message through to the PHP script after doing whatever it is procmail does (one thing I wanted was to split messages to different forums based on the To: or CC: address of the message in question.)
So here's what I need to do:
1) Contact POP3 Server, login.
2) Iterate through each message, look at the to:/cc: header and lookup an int that represents which forum the message belongs with.
3) Call FUD script, pass raw message as stdout, and the int as an arg ('mailinglist.php 1' will tell the script that it should send it to forum 1).
4) Delete messages off the server, wait till next time cron calls us.
I hope that's clear as to what I want to do.