[Bps-public-commit] r13683 - in Net-IMAP-Server: ex
jesse at bestpractical.com
jesse at bestpractical.com
Sun Jun 29 10:47:54 EDT 2008
Author: jesse
Date: Sun Jun 29 10:47:54 2008
New Revision: 13683
Added:
Net-IMAP-Server/ex/
Net-IMAP-Server/ex/trivial-server.pl
Modified:
Net-IMAP-Server/ (props changed)
Net-IMAP-Server/MANIFEST
Log:
r34160 at n11648177230: jesse | 2008-06-29 15:34:13 +0800
* Added a trivial sample server
Modified: Net-IMAP-Server/MANIFEST
==============================================================================
--- Net-IMAP-Server/MANIFEST (original)
+++ Net-IMAP-Server/MANIFEST Sun Jun 29 10:47:54 2008
@@ -1,5 +1,6 @@
certs/server-cert.pem
certs/server-key.pem
+ex/trivial-server.pl
Changes
inc/Module/Install.pm
inc/Module/Install/Base.pm
Added: Net-IMAP-Server/ex/trivial-server.pl
==============================================================================
--- (empty file)
+++ Net-IMAP-Server/ex/trivial-server.pl Sun Jun 29 10:47:54 2008
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+use Net::IMAP::Server;
+
+package Demo::IMAP::Auth; $INC{'Demo/IMAP/Auth.pm'} = 1;
+use base 'Net::IMAP::Server::DefaultAuth';
+sub auth_plain {
+ my ( $self, $user, $pass ) = @_;
+ # XXX DO AUTH CHECK
+ return 1;
+}
+
+package Demo::IMAP::Model; $INC{'Demo/IMAP/Model.pm'} = 1;
+use base 'Net::IMAP::Server::DefaultModel';
+
+sub init {
+ my $self = shift;
+ $self->root( Demo::IMAP::Mailbox->new() );
+ $self->root->add_child( name => "INBOX", is_inbox => 1);
+}
+
+package Demo::IMAP::Mailbox;
+use base qw/Net::IMAP::Server::Mailbox/;
+
+my $data = <<'EOF';
+From: jesse at example.com
+To: user at example.com
+Subject: This is a test message!
+
+Hello. I am executive assistant to the director of
+Bear Stearns, a failed investment Bank. I have
+access to USD6,000,000. ...
+EOF
+
+my $msg = Net::IMAP::Server::Message->new($data);
+
+sub load_data {
+ my $self = shift;
+ $self->add_message($msg);
+}
+
+Net::IMAP::Server->new(
+ auth_class => "Demo::IMAP::Auth",
+ model_class => "Demo::IMAP::Model",
+ user => 'nobody',
+ port => 143,
+ ssl_port => 993 )->run();
+
More information about the Bps-public-commit
mailing list