Solved

I want to take this script to the next level

Posted on 2004-03-24
6
200 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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

22 Experts available now in Live!

Get 1:1 Help Now