Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Email Proxy System

by tomazos (Deacon)
on Sep 26, 2005 at 06:54 UTC ( [id://495018]=perlquestion: print w/replies, xml ) Need Help??

tomazos has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on implementing an email "Proxy" system and I seek guidance on which CPAN modules to reuse.

All incoming mail to the domain goes to a mailbox accessible to my code via POP.

The Proxy needs to access the POP mailbox and reject some of the messages based on the headers. (Is there a standard way of rejecting a message? Module?)

Then it needs to append something to the end of some of the messages. (with sensetivity to whether they are in plain text or HTML)

Then it needs to "move" the remaining messages to a bunch of different "mailboxes" for each user. I have MySQL setup, so I was thinking about storing them there.

The users login to the Proxy via POP on a custom port to download their messages.

The other way, I need a custom SMTP server for the users to send their outgoing mail through. The proxy needs to make some changes to the headers and then resend them through the real SMTP server.

So I think basically I need modules for a POP server, a POP client, an SMTP server, an SMTP client and modules for reading and altering email messages.

Any ideas about which CPAN modules I will need to glue together to make this work?

-Andrew.


Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com

Replies are listed 'Best First'.
Re: Email Proxy System
by demerphq (Chancellor) on Sep 26, 2005 at 08:27 UTC

    I've done something like this in the past and I used MIME::Parser and MIME::Lite for it. I used a SMTP server for the sending, but for various stupid reasons I needed to use VB in Outlook to handle the receipt function. Thus I can't recommend any Perl solution for that aspect. (Although i see Mail::Box mentioned favourably quite often, so perhaps thats a good place to look).

    Just so you know you'll need to be very careful about how you rebundle the mail. By blindly appending content to the end of signed or encrypted mail you can make the mail look forged or break the encryption. IE, its critical that you analyse the MIME container structure to make sure you dont mangle anything.

    Good luck.

    ---
    $world=~s/war/peace/g

Re: Email Proxy System
by Anonymous Monk on Sep 26, 2005 at 13:49 UTC
    Who needs Perl for this?

    Modern mail daemons like qmail, sendmail, postfix, etc can do the filtering, message/header modification and sorting into local mailboxes easily - with or without the help of an external program like procmail. And they can do it both for incoming, and outgoing email.

    To fetch mail, I'd use fetchmail.

    Heck, I've done most of the stuff you've discribed more than once - and always with qmail/fetchmail/procmail. They are written with the purpose of doing this stuff, so why reinvent the wheel?

Re: Email Proxy System
by jasonk (Parson) on Sep 26, 2005 at 13:31 UTC

    You will need to replace POP with something else (like IMAP) in order to meet your requirements. Some of the things you want to do (append to the end of the message, move messages between mailboxes) are not possible through POP (See RFC 1939), as the POP protocol does not provide for you to modify the mail on the server (other than to delete the message), it requires you to download the message and store it locally if you want to do that.


    We're not surrounded, we're in a target-rich environment!
      My script will be run locally on the server. I suppose what I was going to do was download the mail from the mailbox to my script with a POP client module (deleting them from the mailbox afterwards). Then store and mess with the messages within my own database system - then use a POP server module messages to the users' email clients.

      -Andrew.


      Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://495018]
Approved by holli
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-25 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found