Solved

PHP script to pipe POP3 messages to STDout

Posted on 2003-11-20
8
368 Views
Last Modified: 2009-07-29
Hi All;

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.
0
Comment
Question by:Squeebee
  • 5
  • 3
8 Comments
 
LVL 17

Author Comment

by:Squeebee
ID: 9791829
I should probably point out that the php script to be called handles one raw html message for each time it is called.
0
 
LVL 14

Accepted Solution

by:
ThG earned 500 total points
ID: 9796387
This shouldn't be too hard. This is where to start from:

To connect to a POP3 server on port 110 on the local server, use:
$mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");

Read carefully:
http://it2.php.net/manual/en/ref.imap.php

Then you're going to need:
http://it.php.net/popen

with the "w" mode, of course.
Start reading the documentation, i'll assist you in writing the script.
0
 
LVL 17

Author Comment

by:Squeebee
ID: 9799233
Ok, I will work on it this weekend. I was hoping something out there would be premade, but this is ok.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 14

Expert Comment

by:ThG
ID: 9799378
Well, I don't exclude it. I haven't got a good "what's-out-there" knowledge. It usually takes me less time to write something myself rather than looking for it on the web.
If you also include learning about how the thing works, solving initial troubles, and eventually debugging it.. you can be sure that it's better to write it yourself..
0
 
LVL 17

Author Comment

by:Squeebee
ID: 9799756
Agreed
0
 
LVL 17

Author Comment

by:Squeebee
ID: 9799820
I have just been made aware that the script I need has already been written by a fellow FUDforum user, as such I will take an approach of using an improving rather than writing from scratch. That being said, I appreciate you help, useful links, and willingness to assist.
0
 
LVL 14

Expert Comment

by:ThG
ID: 9801012
Pleased to help you, as i could. :-)
0
 
LVL 17

Author Comment

by:Squeebee
ID: 9801589
This looks like I will need to make some improvements, so I think I will be back.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question