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

I want to take this script to the next level

Posted on 2004-03-24
6
203 Views
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(
                "mysql@lists.mysql.com",
                "myodbc@lists.mysql.com",
                "win32@lists.mysql.com"
                );

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.
0
Comment
Question by:Squeebee
  • 3
  • 3
6 Comments
 
LVL 1

Assisted Solution

by:robinet02
robinet02 earned 500 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 :

$dest_address['mysql@lists.mysql.com']++;
$dest_address[myodbc@lists.mysql.com']++;
$dest_address['win32@lists.mysql.com']++;

Then you can add all the addresses from the 'To:' field of your email by using :
$dest_address[$to_email_address]++;

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, ...)
}


0
 
LVL 17

Author Comment

by:Squeebee
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.
0
 
LVL 1

Assisted Solution

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

www.phpguru.org/mime.decode.html

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 ?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
LVL 17

Author Comment

by:Squeebee
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.
0
 
LVL 1

Accepted Solution

by:
robinet02 earned 500 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)
0
 
LVL 17

Author Comment

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

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

856 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