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

For assorted reasons, I've been contemplating putting together a sort of proxy for email. It would use Mail::POP3Client to retrieve stuff from the real server, possibly filter it, possibly annotate it with a header, and store it (probably one file for each message in a directory for each user account) along with some metadata (e.g., when it was pulled down from the server, which clients have retrieved it, and so forth) and then allow real mail clients to retrieve the messages. The messages would be permanently stored but would not be given to the same client app twice. (Thus, I could get my mail on more than one PC, test out beta mail clients, and so forth.) I would be writing it in a modular and hopefully extensible fashion so that it could be reused for things like spam filtering. As an added bonus, it could retrieve from the server on a cron job and so keep the ISP account from filling up if you take to long getting around to getting your mail (say, if you go away on vacation).

The part I need help with is serving out the mail. I tried to search CPAN for a mail server module, but I didn't find one. Maybe I used the wrong search words? I found an SMTP server module, but that won't help; I need POP3 or IMAP -- ideally both. My code can handle the logic of determining what messages are available and retrieving them from storage and so on, but I was hoping to find a module to handle the actual protocol(s). There's plenty of code on CPAN for the client side of these protocols, but I'm not finding POP3 or IMAP servers. There's Net::Server, of course, but do I really have to bite the bullet and implement the protocol RFCs?


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

Replies are listed 'Best First'.
Re: Modules for _serving_ email
by b10m (Vicar) on Dec 30, 2003 at 18:33 UTC

      Ah, for some reason all my searching didn't find those. I'll definitely look into them; thanks for pointing them out. If they are what they sound like, they could save me even more of the work than what I was looking for. (Though, I originally started out looking for a POP3 proxy, but I didn't turn one up, perhaps because CPAN doesn't know a proxy and a relay are the same, or perhaps because I didn't try looking for POP without the 3.)

      update: Upon further inspection, the docs for these aren't as clear as I would like, but it *appears* to me as though they are a relay in the sense of receiving the message and passing it along to another account. One of the configuration options you have to set is for what process is the "mail program service"; the default is sendmail. So as near as I can determine, it wants to pass the message along to an MTA. That isn't at all what I want. Also, I examined the source of both modules and did not find any evidence of any network protocols being implemented, specifically not POP3.


      $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
Re: Modules for _serving_ email
by jonadab (Parson) on Jan 02, 2004 at 23:49 UTC

    Well, as it turns out, nobody has been able to point me to modules that do what I want, so I'm going to have to implement them myself. I'm starting with POP3 and will probably call the module Net::Server::POP3. If all goes well, I plan to put it up on CPAN, along with a sample script that uses it. If all goes _really_ well, I'd like to do IMAP as well.

    update: Well, it's not ready for primetime, but I have something that mostly works. I uploaded version 0.0001 to PAUSE today and applied for the namespace. What I have so far can be found in my author directory on CPAN.


    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/