Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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
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
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
Suggested Courses

636 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