Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP script to pipe POP3 messages to STDout

Posted on 2003-11-20
8
Medium Priority
?
373 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
[X]
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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

721 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