Solved

PHP script to pipe POP3 messages to STDout

Posted on 2003-11-20
8
366 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now