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

I'm currently working on something which ideally would have a 'virtual' email system for mobile phones, in that a client's phone connects and gets a list of the possible email topics, and then when they chose which one they want the actual content is generated on the fly and sent as a body text.

This kind of dynamic content generation pretty much rules out any standard POP3/IMAP server, and pregenerating all topics would be extremely network intensive as it requires numerous HTML pages to be fetched, so I reasoned it made sense to implement the virtual server in Perl. I've searched CPAN, Perlmonks, and Google however and can't find any kind of Perl module for POP3 or IMAP servers.

I do know about the client modules, and the Net::Server modules, but I am surprised nothing exists to do the actual server-side of the protocols.

Am I overlooking something, or is this genuinely a wheel which has yet to be built?

Replies are listed 'Best First'.
Re: POP3/IMAP Server modules?
by tachyon (Chancellor) on Apr 12, 2003 at 23:23 UTC

    but I am surprised nothing exists to do the actual server-side of the protocols

    Why? The protocols are well defined, there are stable (mature & feature rich), C based (fast), GNU (free)solutions readily available for all the major defined protocols.

    That said have a look at CGI::WML and modules like Apache::WAP::MailPeek and Apache::WAP::AutoIndex which let you combine WAP/Apache/mod_perl and will probably let you do exactly what you want.

    cheers

    tachyon

      The reason 'why' is because I really expected there to be a Perl version as there is no good reason someone wouldn't have tried anything similar before.

      As you say, the protocols are well-defined and so building to their specification shouldn't involve too much hunting round for obscure exceptions.

      The C implementations are great providing you're doing what it's intended to do (ie. serve mail from a static file), but I do tend to view CPAN as a wonderful resource for getting simple-to-use implementations of common protocols and I do view POP3 as an exceptionally common one. There are also very fast C implementations of things such as web servers, but I'd expect Perl to have it's own modules to handle raw HTTP requests.

      I did find references of an entire POP3 server implemented in Perl, but at the time couldn't find it, so I do know people have tried things like this in the past.

      Thanks for the pointers to the WML/WAP modules. I can see these would suit for many needs, but for this I do need to be able to keep data in long-term storage until the user deletes it, as part of the project is intended to provide an offline browser of sorts.

Re: POP3/IMAP Server modules?
by bbfu (Curate) on Apr 13, 2003 at 17:50 UTC

    Actually, I just made Net::Server::POP3::Skeleton over the last few weeks. I haven't quite finished documenting it, but it should be what you need. Obviously, it's Net::Server based, and you have to implement most of the commands yourself, but all the commands are trivial to implement.

    (Update: In case you're planning on running this on Win32, I just want to let you know that Net::Server does work on Win32. The forking personality (the one this code uses by default) requires perl 5.8 because there was a bug in the fork emulation in 5.6 that caused perl to crash, and I had a problem with the tests hanging (due to a call to POSIX::setsid which doesn't work on Win32) but it works fine if you just skip the tests. Just wanted you to be aware so you don't think you can't use it on Win32. I'm using it on Win32, so I know it works. :p)

    I wrote an implementation using Mail::Webmail::Yahoo so that I could access my Yahoo email via my POP3 client. If you want to see an implementation of the various commands, let me know and I'll post my Yahoo mail module, too.

    Click readmore to see the code:
    (Code updated and moved to Net::Server::POP3::Skeleton)

    HTH

    Update: Updated the code and it's POD a little bit.

    Update: As per request via /msg, I'm including my implementation of a server. It basically creates a proxy-type POP3 server that accesses and manipulates the messages directly via Yahoo's website.

    Note that this code uses a modified version of Mail::Webmail::Yahoo, as the normal copy didn't work correctly out of the box and didn't include a way to move / delete messages. So the code almost definately won't run using the vanilla Mail::Webmail::Yahoo. Eventually, I hope to factor my changes out of the Mail::Webmail::Yahoo module and into my code, though I'm not sure how feasable that is...

    Click readmore for the implementation code

    bbfu
    Black flowers blossom
    Fearless on my breath