Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PHP script to pipe POP3 messages to STDout

Posted on 2003-11-20
8
369 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP AJAX JSON 2 75
Custom Wordpress Loop 22 38
Correct syntax for subdirectories 9 18
Ajax and PHP 4 29
This article discusses how to create an extensible mechanism for linked drop downs.
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.

789 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