Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP script to pipe POP3 messages to STDout

Posted on 2003-11-20
8
Medium Priority
?
374 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 2000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

927 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