[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


I want to take this script to the next level

Posted on 2004-03-24
Medium Priority
Last Modified: 2008-03-03
Hi All;

The script is at http://www.vbmysql.com/fudmail.phps

Summary: This script is for use with FUDforum (http://fud.prohost.org). FUDforum has a great feature for mirroring Mailing lists so that mailing list posts end up in a FUDforum forum, but it's currently limited to using procmail as a source for emails. This script uses the standard IMAP tools to hook to a POP server and grab the latest emails, it then does some cleanup and tries to determine which list is targeted, then pipes it to the fudmail mail handler script.

It determines which list to point to with the following:

$mailing_lists = array(

This script is working, but I know that my newbieness is getting in the way of it being even better. Here's the things I need to do:

1) If someone cross-posts to all three lists, the email shows up three times in each mirror forum. I am not sure why it would get piped three times to each of the three lists but I would like to fix this.

2) Some of these lists have aliases at the list server (win32@lists.mysql.com can also be mysql-win32@lists.mysql.com). So I think I need to go to a two-dimensional array approach where you give a list name and a script-id code that says which list gets piped to (currently the script ID is the array position + 1 i.e. element 0 has an id of 1 which gets passed to the FUD mailer script. The script uses the id to know which forum to post the message to).

I would love some help with these things and any other tips that can be given for making this script better.
Question by:Squeebee
  • 3
  • 3

Assisted Solution

robinet02 earned 2000 total points
ID: 10675214
It seems to me that your problem is from the 'To:' field of the original email.
This field may contain multiple destination addresses.
This means that if someone posts to the 3 lists, the script will use everyone of the 3 destination email addresses and issue 3 emails for each = 9 emails in total.

you could use an array like this :


Then you can add all the addresses from the 'To:' field of your email by using :

If this destination is already among the array member, the value will just be increased by one.

Then, you process the emails like this :

foreach ($dest_address as $destination_email_address) {
      mail($destination_email_address, ...)

LVL 17

Author Comment

ID: 10686927
This script is not mailing out. It is processing incoming email and piping it to a script that inserts the email into a forum. As such the To: field is already populated, the challenge is interpreting it.

Thanks for the suggestion though.

Assisted Solution

robinet02 earned 2000 total points
ID: 10693956
I had some difficulties to handle MIME emails in php but found recently this class :


it helps to parse the email message, even if you do not have the IMAP extensions available.
You have then access to the "to" content-field, which you can parse easily with preg_match or preg_match_all, first for email_addresses enclosed between brackets ("<" and ">") and then for addresses without brackets.

Does this answer your needs ?
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 17

Author Comment

ID: 10695378
Actually I am parsing the headers just fine at this point, the issue is in managing the piping of the emails to a second script.

Accepted Solution

robinet02 earned 2000 total points
ID: 10695682
By "managing", you mean avoiding to spread the SAME email many times ?
In this case, you could use an MD5 checksum.
When a new mail is added to the second script, you store its MD5 checksum, and you refuse any new email with the same ...
So, you won't get anymore the same email posted 3 times ...
To calculate an MD5 is easy : md5($script_content)
LVL 17

Author Comment

ID: 12079013
Just closing this. In the end I switched to regular expressions.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

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.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

873 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