How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!

Ricardo Signes
Ricardo Signescomputer programmer at Pobox.com
Perl
          Email
          Project
the 2007 PEP talk!!!
How I Learned To
 Stop Worrying
      and
   Love Email
rjbs
@cpan.org
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
we’re hiring: http://xrl.us/pobox
Perl Email Project
PEP
Email::
simple
efficient
accurate
less processor time
less memory
fewer classes
fewer methods
LESS OF A PAIN
  IN THE ASS
Make Email
Handling Suck
    Less
writing better modules
maintaining old modules
sharing
knowledge
Modules!
Frameworks
Mail-Box
Email::
Message Objects
Email::Simple
      &
Email::MIME
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
use Email::Simple;
use Email::Simple;

my $email = Email::Simple->new($string);
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
my $email = Email::Simple->create(
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
my $email = Email::Simple->create(
  header => [
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
my $email = Email::Simple->create(
  header => [
    To      => ‘rjbs@cpan.org’,
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
my $email = Email::Simple->create(
  header => [
    To      => ‘rjbs@cpan.org’,
    From    => ‘IRS <the.man@irs.gov>’,
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
my $email = Email::Simple->create(
  header => [
    To      => ‘rjbs@cpan.org’,
    From    => ‘IRS <the.man@irs.gov>’,
    Subject => ‘Please See Me’,
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
my $email = Email::Simple->create(
  header => [
    To      => ‘rjbs@cpan.org’,
    From    => ‘IRS <the.man@irs.gov>’,
    Subject => ‘Please See Me’,
    Keyword => ‘1099’,
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
my $email = Email::Simple->create(
  header => [
    To      => ‘rjbs@cpan.org’,
    From    => ‘IRS <the.man@irs.gov>’,
    Subject => ‘Please See Me’,
    Keyword => ‘1099’,
    Keyword => ‘1040’,
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
my $email = Email::Simple->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
     Keyword => ‘1099’,
     Keyword => ‘1040’,
  ],
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
my $email = Email::Simple->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
     Keyword => ‘1099’,
     Keyword => ‘1040’,
  ],
  body    => “[ insert threatening text here ]”
use Email::Simple;

my $email = Email::Simple->new($string);

use Email::Simple::Creator;
my $email = Email::Simple->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
     Keyword => ‘1099’,
     Keyword => ‘1040’,
  ],
  body    => “[ insert threatening text here ]”
);
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
$email->as_string;
$email->as_string;

$email->header(‘Subject’);
$email->as_string;

$email->header(‘Subject’);

$email->header_set(Subject => ‘Re: mtfnpy’);
$email->as_string;

$email->header(‘Subject’);

$email->header_set(Subject => ‘Re: mtfnpy’);

$email->body;
$email->as_string;

$email->header(‘Subject’);

$email->header_set(Subject => ‘Re: mtfnpy’);

$email->body;

$email->body_set($big_string);
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
use Email::Simple;
use Email::Simple;

my $email = Email::Simple->new( $string );
use Email::Simple;

my $email = Email::Simple->new( $string );
$email->body_set( $new_body );
use Email::Simple;

my $email = Email::Simple->new( $string );
$email->body_set( $new_body );

use Email::Simple::FromHandle;
use Email::Simple;

my $email = Email::Simple->new( $string );
$email->body_set( $new_body );

use Email::Simple::FromHandle;

my $email = Email::SimpleFromHandle->new(
use Email::Simple;

my $email = Email::Simple->new( $string );
$email->body_set( $new_body );

use Email::Simple::FromHandle;

my $email = Email::SimpleFromHandle->new(
  $input_handle
use Email::Simple;

my $email = Email::Simple->new( $string );
$email->body_set( $new_body );

use Email::Simple::FromHandle;

my $email = Email::SimpleFromHandle->new(
  $input_handle
);
use Email::Simple;

my $email = Email::Simple->new( $string );
$email->body_set( $new_body );

use Email::Simple::FromHandle;

my $email = Email::SimpleFromHandle->new(
  $input_handle
);

$email->stream_to($output_handle);
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $email = Email::MIME->new($string);
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
    To      => ‘rjbs@cpan.org’,
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
    To      => ‘rjbs@cpan.org’,
    From    => ‘IRS <the.man@irs.gov>’,
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
    To      => ‘rjbs@cpan.org’,
    From    => ‘IRS <the.man@irs.gov>’,
    Subject => ‘Please See Me’,
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
  ],
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
  ],

 attributes =>
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
  ],

 attributes =>
    { content_type => ‘multipart/mixed’ },
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
  ],

 attributes =>
    { content_type => ‘multipart/mixed’ },

  parts   => [
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
  ],

 attributes =>
    { content_type => ‘multipart/mixed’ },

  parts => [
    Email::MIME->create(...),
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
  ],

 attributes =>
    { content_type => ‘multipart/mixed’ },

  parts => [
    Email::MIME->create(...),
    Email::MIME->create(...),
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
  ],

 attributes =>
    { content_type => ‘multipart/mixed’ },

  parts => [
     Email::MIME->create(...),
     Email::MIME->create(...),
  ],
my $email = Email::MIME->new($string);

use Email::MIME::Creator;
my $email = Email::MIME->create(
  header => [
     To      => ‘rjbs@cpan.org’,
     From    => ‘IRS <the.man@irs.gov>’,
     Subject => ‘Please See Me’,
  ],

 attributes =>
    { content_type => ‘multipart/mixed’ },

  parts => [
     Email::MIME->create(...),
     Email::MIME->create(...),
  ],
);
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
$email->subparts;
$email->subparts;

$email->parts_set(@parts);
$email->subparts;

$email->parts_set(@parts);

$email->body_raw;
problems
problems

still not efficient enough
problems

still not efficient enough
FromHandle doesn’t do MIME
problems

still not efficient enough
FromHandle doesn’t do MIME
Email::MIME doesn’t stream
problems

still not efficient enough
FromHandle doesn’t do MIME
Email::MIME doesn’t stream
fairly small feature set*
MIME::Entity
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity = MIME::Entity->build(
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity = MIME::Entity->build(
  To      => ‘rjbs@cpan.org’,
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity = MIME::Entity->build(
  To      => ‘rjbs@cpan.org’,
  From    => ‘IRS <the.man@irs.gov>’,
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity =   MIME::Entity->build(
  To      =>   ‘rjbs@cpan.org’,
  From    =>   ‘IRS <the.man@irs.gov>’,
  Subject =>   ‘Please See Me’,
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity =   MIME::Entity->build(
  To      =>   ‘rjbs@cpan.org’,
  From    =>   ‘IRS <the.man@irs.gov>’,
  Subject =>   ‘Please See Me’,
  ‘Keyword:’   => [ 1099, 1040 ],
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity =   MIME::Entity->build(
  To      =>   ‘rjbs@cpan.org’,
  From    =>   ‘IRS <the.man@irs.gov>’,
  Subject =>   ‘Please See Me’,
  ‘Keyword:’   => [ 1099, 1040 ],
  Data    =>   [ “This might be an audit.” ],
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity =   MIME::Entity->build(
  To      =>   ‘rjbs@cpan.org’,
  From    =>   ‘IRS <the.man@irs.gov>’,
  Subject =>   ‘Please See Me’,
  ‘Keyword:’   => [ 1099, 1040 ],
  Data    =>   [ “This might be an audit.” ],
);
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity =   MIME::Entity->build(
  To      =>   ‘rjbs@cpan.org’,
  From    =>   ‘IRS <the.man@irs.gov>’,
  Subject =>   ‘Please See Me’,
  ‘Keyword:’   => [ 1099, 1040 ],
  Data    =>   [ “This might be an audit.” ],
);

$entity->attach(
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity =   MIME::Entity->build(
  To      =>   ‘rjbs@cpan.org’,
  From    =>   ‘IRS <the.man@irs.gov>’,
  Subject =>   ‘Please See Me’,
  ‘Keyword:’   => [ 1099, 1040 ],
  Data    =>   [ “This might be an audit.” ],
);

$entity->attach(
  Path => ‘./reports/audit-results.pdf’,
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity =   MIME::Entity->build(
  To      =>   ‘rjbs@cpan.org’,
  From    =>   ‘IRS <the.man@irs.gov>’,
  Subject =>   ‘Please See Me’,
  ‘Keyword:’   => [ 1099, 1040 ],
  Data    =>   [ “This might be an audit.” ],
);

$entity->attach(
  Path => ‘./reports/audit-results.pdf’,
  Type => ‘application/pdf’,
my $entity = MIME::Entity->new($input_handle);
my $entity = MIME::Entity->new(@lines);

my $entity =   MIME::Entity->build(
  To      =>   ‘rjbs@cpan.org’,
  From    =>   ‘IRS <the.man@irs.gov>’,
  Subject =>   ‘Please See Me’,
  ‘Keyword:’   => [ 1099, 1040 ],
  Data    =>   [ “This might be an audit.” ],
);

$entity->attach(
  Path => ‘./reports/audit-results.pdf’,
  Type => ‘application/pdf’,
);
problems
problems
really big (loads 50+ extra
modules)
problems
really big (loads 50+ extra
modules)
large, sometimes confusing
interface
problems
really big (loads 50+ extra
modules)
large, sometimes confusing
interface
history of subtle bugs
Mail::Message
 (a Mail::Box Production)
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $mail = Mail::Message->read($input_handle);
my $mail = Mail::Message->read($input_handle);

my $mail = Mail::Message->build(
my $mail = Mail::Message->read($input_handle);

my $mail = Mail::Message->build(
  To      => ‘rjbs@cpan.org’,
my $mail = Mail::Message->read($input_handle);

my $mail = Mail::Message->build(
  To      => ‘rjbs@cpan.org’,
  From    => ‘IRS <the.man@irs.gov>’,
my $mail = Mail::Message->read($input_handle);

my $mail = Mail::Message->build(
  To      => ‘rjbs@cpan.org’,
  From    => ‘IRS <the.man@irs.gov>’,
  Subject => ‘Please See Me’,
my $mail = Mail::Message->read($input_handle);

my $mail = Mail::Message->build(
  To      => ‘rjbs@cpan.org’,
  From    => ‘IRS <the.man@irs.gov>’,
  Subject => ‘Please See Me’,
  Keyword => 1099,
my $mail = Mail::Message->read($input_handle);

my $mail = Mail::Message->build(
  To      => ‘rjbs@cpan.org’,
  From    => ‘IRS <the.man@irs.gov>’,
  Subject => ‘Please See Me’,
  Keyword => 1099,
  Keyword => 1040,
my $mail = Mail::Message->read($input_handle);

my $mail = Mail::Message->build(
  To      => ‘rjbs@cpan.org’,
  From    => ‘IRS <the.man@irs.gov>’,
  Subject => ‘Please See Me’,
  Keyword => 1099,
  Keyword => 1040,
my $mail = Mail::Message->read($input_handle);

my $mail = Mail::Message->build(
  To      => ‘rjbs@cpan.org’,
  From    => ‘IRS <the.man@irs.gov>’,
  Subject => ‘Please See Me’,
  Keyword => 1099,
  Keyword => 1040,

  data    => “This might be an audit.n”,
my $mail = Mail::Message->read($input_handle);

my $mail = Mail::Message->build(
  To      => ‘rjbs@cpan.org’,
  From    => ‘IRS <the.man@irs.gov>’,
  Subject => ‘Please See Me’,
  Keyword => 1099,
  Keyword => 1040,

  data    => “This might be an audit.n”,
  file    => ‘./reports/audit-results.pdf’,
my $mail = Mail::Message->read($input_handle);

my $mail = Mail::Message->build(
  To      => ‘rjbs@cpan.org’,
  From    => ‘IRS <the.man@irs.gov>’,
  Subject => ‘Please See Me’,
  Keyword => 1099,
  Keyword => 1040,

  data    => “This might be an audit.n”,
  file    => ‘./reports/audit-results.pdf’,
);
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
$mail->string;
$mail->string;

$mail->head->get(‘Subject’);
$mail->string;

$mail->head->get(‘Subject’);

$mail->head->delete(‘X-Pointles’);
$mail->string;

$mail->head->get(‘Subject’);

$mail->head->delete(‘X-Pointles’);

$mail->head->reset(Subject => “I’m on TV!”);
$mail->string;

$mail->head->get(‘Subject’);

$mail->head->delete(‘X-Pointles’);

$mail->head->reset(Subject => “I’m on TV!”);

$mail->body(
$mail->string;

$mail->head->get(‘Subject’);

$mail->head->delete(‘X-Pointles’);

$mail->head->reset(Subject => “I’m on TV!”);

$mail->body(
  Mail::Message::Body->new(data => $data),
$mail->string;

$mail->head->get(‘Subject’);

$mail->head->delete(‘X-Pointles’);

$mail->head->reset(Subject => “I’m on TV!”);

$mail->body(
  Mail::Message::Body->new(data => $data),
);
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
$mail->body->parts;
$mail->body->parts;

$mail->body->attach(@things);
$mail->body->parts;

$mail->body->attach(@things);
$mail->body->part(1)->delete;
$mail->body->parts;

$mail->body->attach(@things);
$mail->body->part(1)->delete;

my @parts = $mail->body->parts(
$mail->body->parts;

$mail->body->attach(@things);
$mail->body->part(1)->delete;

my @parts = $mail->body->parts(
  sub { $_[0]->mimeType eq ‘text/html }
$mail->body->parts;

$mail->body->attach(@things);
$mail->body->part(1)->delete;

my @parts = $mail->body->parts(
  sub { $_[0]->mimeType eq ‘text/html }
);
$mail->body->parts;

$mail->body->attach(@things);
$mail->body->part(1)->delete;

my @parts = $mail->body->parts(
  sub { $_[0]->mimeType eq ‘text/html }
);
$_->delete for @parts;
$mail->body->parts;

$mail->body->attach(@things);
$mail->body->part(1)->delete;

my @parts = $mail->body->parts(
  sub { $_[0]->mimeType eq ‘text/html }
);
$_->delete for @parts;
$mail->body->rebuild;
problems
problems

really big (loads 40+ extra
modules)
problems

really big (loads 40+ extra
modules)
large, sometimes confusing
interface
Mail::Internet
Mail::Internet
MIME::Lite
MIME::Lite
Email::Abstract
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $abstract = Email::Abstract->new($thing);
my $abstract = Email::Abstract->new($thing);
my $abstract = Email::Abstract->new($thing);

$abstract->get_header(‘Subject’);
my $abstract = Email::Abstract->new($thing);

$abstract->get_header(‘Subject’);
$abstract->set_header(Subject => ‘Foo!’);
my $abstract = Email::Abstract->new($thing);

$abstract->get_header(‘Subject’);
$abstract->set_header(Subject => ‘Foo!’);
my $abstract = Email::Abstract->new($thing);

$abstract->get_header(‘Subject’);
$abstract->set_header(Subject => ‘Foo!’);

$abstract->get_body;
my $abstract = Email::Abstract->new($thing);

$abstract->get_header(‘Subject’);
$abstract->set_header(Subject => ‘Foo!’);

$abstract->get_body;
$abstract->set_body(‘This is a short body!’);
my $abstract = Email::Abstract->new($thing);

$abstract->get_header(‘Subject’);
$abstract->set_header(Subject => ‘Foo!’);

$abstract->get_body;
$abstract->set_body(‘This is a short body!’);
my $abstract = Email::Abstract->new($thing);

$abstract->get_header(‘Subject’);
$abstract->set_header(Subject => ‘Foo!’);

$abstract->get_body;
$abstract->set_body(‘This is a short body!’);

$abstract->as_string;
my $abstract = Email::Abstract->new($thing);

$abstract->get_header(‘Subject’);
$abstract->set_header(Subject => ‘Foo!’);

$abstract->get_body;
$abstract->set_body(‘This is a short body!’);

$abstract->as_string;
my $abstract = Email::Abstract->new($thing);

$abstract->get_header(‘Subject’);
$abstract->set_header(Subject => ‘Foo!’);

$abstract->get_body;
$abstract->set_body(‘This is a short body!’);

$abstract->as_string;

$abstract->cast(‘Mail::Internet’);
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
Email::Simple & ::MIME
Email::Simple & ::MIME
MIME::Entity
Email::Simple & ::MIME
MIME::Entity
Mail::Internet
Email::Simple & ::MIME
MIME::Entity
Mail::Internet
Mail::Message
Email::Simple & ::MIME
MIME::Entity
Mail::Internet
Mail::Message
more coming
problems
problems

missing some key methods
problems

missing some key methods
needs more testing for
complex message types
problems

missing some key methods
needs more testing for
complex message types
can be inefficient
suggestion
suggestion

learn all of Email::Simple and
most of Email::MIME
suggestion

learn all of Email::Simple and
most of Email::MIME
for sending your own simple
emails, use these
suggestion
suggestion

learn the basics of Mail::Message
suggestion

learn the basics of Mail::Message
use it if you know you’ll need to use
more of Mail::Box in the future
suggestion

learn the basics of Mail::Message
use it if you know you’ll need to use
more of Mail::Box in the future
use it if you have complex encoding or
MIME-handling requirements
suggestion
suggestion

learn the basics of handling
MIME::Entity messages
suggestion

learn the basics of handling
MIME::Entity messages
lots of code uses them
suggestion

learn the basics of handling
MIME::Entity messages
lots of code uses them
use MIME::Entity when you need to
cope with crappy input that nothing
else can parse
suggestion
suggestion

if you write an API that is passed an
email message, consider using
Abstract
suggestion

if you write an API that is passed an
email message, consider using
Abstract
if it exists primarily for handling
email, pick a more complete library to
use, and stick to it.
Email Collections
Mail::Box
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $maildir = Mail::Box::Maildir->new
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);

my $message = $maildir->message(4);
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);

my $message = $maildir->message(4);
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);

my $message = $maildir->message(4);

$message->delete;
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);

my $message = $maildir->message(4);

$message->delete;
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);

my $message = $maildir->message(4);

$message->delete;

my $newmsg = Mail::Message->new(...);
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);

my $message = $maildir->message(4);

$message->delete;

my $newmsg = Mail::Message->new(...);
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);

my $message = $maildir->message(4);

$message->delete;

my $newmsg = Mail::Message->new(...);

$maildir->addMessage($newmsg);
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);

my $message = $maildir->message(4);

$message->delete;

my $newmsg = Mail::Message->new(...);

$maildir->addMessage($newmsg);
my $maildir = Mail::Box::Maildir->new
  folder => ‘./Maildir/’,
);

my $message = $maildir->message(4);

$message->delete;

my $newmsg = Mail::Message->new(...);

$maildir->addMessage($newmsg);

$maildir->write;
folders over the net
subfolders
threading
delayed reading
       &
 construction
suggestion
suggestion
if you need to manage
mailboxes, just use it
suggestion
if you need to manage
mailboxes, just use it
there isn’t really any
alternative
suggestion
if you need to manage
mailboxes, just use it
there isn’t really any
alternative
unless you count...
Email::Folder
  (and friends)
a bunch of modules
Email::Feature::Type
Email::FolderType
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
use Email::FolderType qw(folder_type);
use Email::FolderType qw(folder_type);
use Email::FolderType qw(folder_type);

my $type = folder_type(‘./Maildir’);
use Email::FolderType qw(folder_type);

my $type = folder_type(‘./Maildir’);
# => ‘Mbox’
use Email::FolderType qw(folder_type);

my $type = folder_type(‘./Maildir’);
# => ‘Mbox’
use Email::FolderType qw(folder_type);

my $type = folder_type(‘./Maildir’);
# => ‘Mbox’

my $type = folder_type(‘./Maildir/’);
use Email::FolderType qw(folder_type);

my $type = folder_type(‘./Maildir’);
# => ‘Mbox’

my $type = folder_type(‘./Maildir/’);
# => ‘Maildir’
use Email::FolderType qw(folder_type);

my $type = folder_type(‘./Maildir’);
# => ‘Mbox’

my $type = folder_type(‘./Maildir/’);
# => ‘Maildir’
use Email::FolderType qw(folder_type);

my $type = folder_type(‘./Maildir’);
# => ‘Mbox’

my $type = folder_type(‘./Maildir/’);
# => ‘Maildir’

my $type = folder_type(‘./Maildir//’);
use Email::FolderType qw(folder_type);

my $type = folder_type(‘./Maildir’);
# => ‘Mbox’

my $type = folder_type(‘./Maildir/’);
# => ‘Maildir’

my $type = folder_type(‘./Maildir//’);
# => Ezmlm
Email::Folder
Email::Folder::Reader
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $reader = Email::Folder->new(“./Maildir/”);
my $reader = Email::Folder->new(“./Maildir/”);
my $reader = Email::Folder->new(“./Maildir/”);

while (my $email = $reader->next_message) {
my $reader = Email::Folder->new(“./Maildir/”);

while (my $email = $reader->next_message) {
  print “to delete!”
my $reader = Email::Folder->new(“./Maildir/”);

while (my $email = $reader->next_message) {
  print “to delete!”
    if $email->header(‘from’) =~ /Laura/i;
my $reader = Email::Folder->new(“./Maildir/”);

while (my $email = $reader->next_message) {
  print “to delete!”
    if $email->header(‘from’) =~ /Laura/i;
}
Email::Delete
my $reader = Email::Folder->new(“./Maildir/”);

while (my $email = $reader->next_message) {
  $email->delete
    if $email->header(‘from’) =~ /Laura/i;
}
E
                                    D
                                O
                              C
my $reader = Email::Folder->new(“./Maildir/”);


                       L
                     A
while (my $email = $reader->next_message) {

                E
              R
  $email->delete


    T
    if $email->header(‘from’) =~ /Laura/i;

  O
}

 N
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
delete_message(
delete_message(
  from     => “./Maildir/”,
delete_message(
  from     => “./Maildir/”,
  matching => sub {
delete_message(
  from     => “./Maildir/”,
  matching => sub {
    shift->header(‘message-id’)
delete_message(
  from     => “./Maildir/”,
  matching => sub {
    shift->header(‘message-id’)
    eq
delete_message(
  from     => “./Maildir/”,
  matching => sub {
    shift->header(‘message-id’)
    eq
    $email->header(‘message-id’)
delete_message(
  from      => “./Maildir/”,
  matching => sub {
    shift->header(‘message-id’)
     eq
     $email->header(‘message-id’)
  },
delete_message(
   from      => “./Maildir/”,
   matching => sub {
     shift->header(‘message-id’)
      eq
      $email->header(‘message-id’)
   },
);
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $reader = Email::Folder->new(“./Maildir/”);
my $reader = Email::Folder->new(“./Maildir/”);
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;

delete_message(
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;

delete_message(
  from     => “./Maildir”,
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;

delete_message(
  from     => “./Maildir”,
  matching => sub { my $email = shift;
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;

delete_message(
  from     => “./Maildir”,
  matching => sub { my $email = shift;
    $email->header(‘references’)
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;

delete_message(
  from     => “./Maildir”,
  matching => sub { my $email = shift;
    $email->header(‘references’)
    and
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;

delete_message(
  from     => “./Maildir”,
  matching => sub { my $email = shift;
    $email->header(‘references’)
    and
    ! $saw_id{ $email->header(‘references’) }
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;

delete_message(
  from      => “./Maildir”,
  matching => sub { my $email = shift;
    $email->header(‘references’)
     and
     ! $saw_id{ $email->header(‘references’) }
  },
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;

delete_message(
  from       => “./Maildir”,
   matching => sub { my $email = shift;
     $email->header(‘references’)
      and
      ! $saw_id{ $email->header(‘references’) }
   },
);
my $reader = Email::Folder->new(“./Maildir/”);

$saw_id{ $_->header(‘message-id’) } = 1
  while my $_ = $reader->next_message;

delete_message(
  from       => “./Maildir”,
   matching => sub { my $email = shift;
     $email->header(‘references’)
      and
      ! $saw_id{ $email->header(‘references’) }
   },
);
so, we can delete
(sort of)
how do we add?
Email::LocalDelivery
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
@successes = Email::LocalDelivery->deliver(
@successes = Email::LocalDelivery->deliver(
  $string,
@successes = Email::LocalDelivery->deliver(
  $string,
  ‘./Maildir/’,
@successes = Email::LocalDelivery->deliver(
  $string,
  ‘./Maildir/’,
  ‘/var/spool/mail/rjbs’,
@successes = Email::LocalDelivery->deliver(
  $string,
  ‘./Maildir/’,
  ‘/var/spool/mail/rjbs’,
  ‘imap://rjbs@mailstore.pobox.com/INBOX’,
@successes = Email::LocalDelivery->deliver(
  $string,
  ‘./Maildir/’,
  ‘/var/spool/mail/rjbs’,
  ‘imap://rjbs@mailstore.pobox.com/INBOX’,
);
@successes = Email::LocalDelivery->deliver(
  $string,
  ‘./Maildir/’,
  ‘/var/spool/mail/rjbs’,
  ‘imap://rjbs@mailstore.pobox.com/INBOX’,
);
can’t stream the message
must load it all into memory
and then copy it
problems
problems

the pieces don’t fit together
problems

the pieces don’t fit together
can be very inefficient
problems

the pieces don’t fit together
can be very inefficient
difficult to extend
suggestion
suggestion


fine for a quick one-off
suggestion


fine for a quick one-off
not ready for prime time
Net::Protocol
Mail::POP3Client
   Net::POP3
         Net::IMAP
Net::IMAP::Simple
      Mail::IMAPClient
Sending Mail
Mail::Send
Mail::Mailer
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $mailer = Mail::Mailer->new(‘sendmail’);
my $mailer = Mail::Mailer->new(‘sendmail’);
my $mailer = Mail::Mailer->new(‘sendmail’);

$mailer->open({
my $mailer = Mail::Mailer->new(‘sendmail’);

$mailer->open({
  To => [ ‘boss@corp’, ‘boss2@corp’ ],
my $mailer = Mail::Mailer->new(‘sendmail’);

$mailer->open({
  To => [ ‘boss@corp’, ‘boss2@corp’ ],
  Bcc => ‘the.ceo@corp’,
my $mailer = Mail::Mailer->new(‘sendmail’);

$mailer->open({
  To => [ ‘boss@corp’, ‘boss2@corp’ ],
  Bcc => ‘the.ceo@corp’,
  Subject => ‘u sux’,
my $mailer = Mail::Mailer->new(‘sendmail’);

$mailer->open({
  To => [ ‘boss@corp’, ‘boss2@corp’ ],
  Bcc => ‘the.ceo@corp’,
  Subject => ‘u sux’,
});
my $mailer = Mail::Mailer->new(‘sendmail’);

$mailer->open({
  To => [ ‘boss@corp’, ‘boss2@corp’ ],
  Bcc => ‘the.ceo@corp’,
  Subject => ‘u sux’,
});
my $mailer = Mail::Mailer->new(‘sendmail’);

$mailer->open({
  To => [ ‘boss@corp’, ‘boss2@corp’ ],
  Bcc => ‘the.ceo@corp’,
  Subject => ‘u sux’,
});

print $mailer quot;Body of messagequot;;
my $mailer = Mail::Mailer->new(‘sendmail’);

$mailer->open({
  To => [ ‘boss@corp’, ‘boss2@corp’ ],
  Bcc => ‘the.ceo@corp’,
  Subject => ‘u sux’,
});

print $mailer quot;Body of messagequot;;
my $mailer = Mail::Mailer->new(‘sendmail’);

$mailer->open({
  To => [ ‘boss@corp’, ‘boss2@corp’ ],
  Bcc => ‘the.ceo@corp’,
  Subject => ‘u sux’,
});

print $mailer quot;Body of messagequot;;

$mailer->close;
my $mailer = Mail::Mailer->new(‘sendmail’);

$mailer->open({
  To => [ ‘boss@corp’, ‘boss2@corp’ ],
  Bcc => ‘the.ceo@corp’,
  Subject => ‘u sux’,
});

print $mailer quot;Body of messagequot;;

$mailer->close;
# ...and it gets sent
Mail::Sender
my $sender = Mail::Sender->new({
smtp => ‘smtp.haliburton.gov’,
});

$sender->Open({
  from     => 'your@address.com',
  to       => 'other@address.com',
  subject => 'HTML test',
  ctype    => quot;text/htmlquot;,
  encoding => quot;7bitquot;
}) or die $Mail::Sender::Error,quot;nquot;;

while (<$input>) {
$sender->SendEx($_); # no encoding!
};

$sender->Close();
Mail::Sendmail
use Mail::Sendmail;

sendmail(
  To      => ‘guy@2nd.row.org’,
  From    => ‘rjbs@cpan.org’,
  Subject => ‘STFU’,
  Body    => $entire_message_body,
) or die “sendmail: $Mail::Sendmail::error”;
Mail::Transport
 (a Mail::Box Production)
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $sender = Mail::Transport::SMTP->new(
my $sender = Mail::Transport::SMTP->new(
  hostname => ‘nebu.fleet.zion.gov’,
my $sender = Mail::Transport::SMTP->new(
  hostname => ‘nebu.fleet.zion.gov’,
  username => ‘t.anderson@yahoo.com’,
my $sender   = Mail::Transport::SMTP->new(
  hostname   => ‘nebu.fleet.zion.gov’,
  username   => ‘t.anderson@yahoo.com’,
  password   => ‘viagra’,
my $sender   = Mail::Transport::SMTP->new(
  hostname   => ‘nebu.fleet.zion.gov’,
  username   => ‘t.anderson@yahoo.com’,
  password   => ‘viagra’,
);
my $sender   = Mail::Transport::SMTP->new(
  hostname   => ‘nebu.fleet.zion.gov’,
  username   => ‘t.anderson@yahoo.com’,
  password   => ‘viagra’,
);
my $sender   = Mail::Transport::SMTP->new(
  hostname   => ‘nebu.fleet.zion.gov’,
  username   => ‘t.anderson@yahoo.com’,
  password   => ‘viagra’,
);

$sender->send(
my $sender   = Mail::Transport::SMTP->new(
  hostname   => ‘nebu.fleet.zion.gov’,
  username   => ‘t.anderson@yahoo.com’,
  password   => ‘viagra’,
);

$sender->send(
  $message,
my $sender   = Mail::Transport::SMTP->new(
  hostname   => ‘nebu.fleet.zion.gov’,
  username   => ‘t.anderson@yahoo.com’,
  password   => ‘viagra’,
);

$sender->send(
  $message,
  from => $env_sender,
my $sender   = Mail::Transport::SMTP->new(
  hostname   => ‘nebu.fleet.zion.gov’,
  username   => ‘t.anderson@yahoo.com’,
  password   => ‘viagra’,
);

$sender->send(
  $message,
  from => $env_sender,
  to   => $env_rcpt,
my $sender   = Mail::Transport::SMTP->new(
  hostname   => ‘nebu.fleet.zion.gov’,
  username   => ‘t.anderson@yahoo.com’,
  password   => ‘viagra’,
);

$sender->send(
   $message,
  from => $env_sender,
  to    => $env_rcpt,
);
::Exim
::Mailx
::Qmail
::SMTP
::Sendmail
Email::Send
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $sender = Email::Send->new({
my $sender = Email::Send->new({
  mailer      => ‘SMTP’,
my $sender = Email::Send->new({
  mailer      => ‘SMTP’,
  mailer_args => [
my $sender = Email::Send->new({
  mailer      => ‘SMTP’,
  mailer_args => [
    Host => ‘sir-mx-a-lot.plusplus.com’,
my $sender = Email::Send->new({
  mailer      => ‘SMTP’,
  mailer_args => [
    Host => ‘sir-mx-a-lot.plusplus.com’,
    username => ‘rjbs’,
my $sender = Email::Send->new({
  mailer      => ‘SMTP’,
  mailer_args => [
    Host => ‘sir-mx-a-lot.plusplus.com’,
    username => ‘rjbs’,
    password => ‘g0t b4ckUPS’,
my $sender = Email::Send->new({
  mailer       => ‘SMTP’,
  mailer_args => [
     Host => ‘sir-mx-a-lot.plusplus.com’,
     username => ‘rjbs’,
     password => ‘g0t b4ckUPS’,
  ],
my $sender = Email::Send->new({
  mailer       => ‘SMTP’,
  mailer_args => [
     Host => ‘sir-mx-a-lot.plusplus.com’,
     username => ‘rjbs’,
     password => ‘g0t b4ckUPS’,
  ],
});
my $sender = Email::Send->new({
  mailer       => ‘SMTP’,
  mailer_args => [
     Host => ‘sir-mx-a-lot.plusplus.com’,
     username => ‘rjbs’,
     password => ‘g0t b4ckUPS’,
  ],
});
my $sender = Email::Send->new({
  mailer       => ‘SMTP’,
  mailer_args => [
     Host => ‘sir-mx-a-lot.plusplus.com’,
     username => ‘rjbs’,
     password => ‘g0t b4ckUPS’,
  ],
});

my $rv = $sender->send($email);
my $sender = Email::Send->new({
  mailer       => ‘SMTP’,
  mailer_args => [
     Host => ‘sir-mx-a-lot.plusplus.com’,
     username => ‘rjbs’,
     password => ‘g0t b4ckUPS’,
  ],
});

my $rv = $sender->send($email);
my $sender = Email::Send->new({
  mailer       => ‘SMTP’,
  mailer_args => [
     Host => ‘sir-mx-a-lot.plusplus.com’,
     username => ‘rjbs’,
     password => ‘g0t b4ckUPS’,
  ],
});

my $rv = $sender->send($email);

unless ($rv) {
my $sender = Email::Send->new({
  mailer       => ‘SMTP’,
  mailer_args => [
     Host => ‘sir-mx-a-lot.plusplus.com’,
     username => ‘rjbs’,
     password => ‘g0t b4ckUPS’,
  ],
});

my $rv = $sender->send($email);

unless ($rv) {
  die “failed to send: “ . $rv->string;
my $sender = Email::Send->new({
  mailer       => ‘SMTP’,
  mailer_args => [
     Host => ‘sir-mx-a-lot.plusplus.com’,
     username => ‘rjbs’,
     password => ‘g0t b4ckUPS’,
  ],
});

my $rv = $sender->send($email);

unless ($rv) {
  die “failed to send: “ . $rv->string;
}
problems
problems
Return::Value
problems
Return::Value
no envelope sender
problems
Return::Value
no envelope sender
awkward mailer/sender distinction
problems
Return::Value
no envelope sender
awkward mailer/sender distinction
difficult to extend api
problems
Return::Value
no envelope sender
awkward mailer/sender distinction
difficult to extend api
not enough API guaranteed for
interchangeability
Email::Sender?
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $sender = Email::Sender::SMTP->new({
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
  pass => ‘wishiwereanoscarmeyerweiner’,
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
  pass => ‘wishiwereanoscarmeyerweiner’,
});
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
  pass => ‘wishiwereanoscarmeyerweiner’,
});
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
  pass => ‘wishiwereanoscarmeyerweiner’,
});

$sender->send(
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
  pass => ‘wishiwereanoscarmeyerweiner’,
});

$sender->send(
  $email,
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
  pass => ‘wishiwereanoscarmeyerweiner’,
});

$sender->send(
  $email,
  {
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
  pass => ‘wishiwereanoscarmeyerweiner’,
});

$sender->send(
  $email,
  {
    to    => $env_rcpt, # or @env_rcpts
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
  pass => ‘wishiwereanoscarmeyerweiner’,
});

$sender->send(
  $email,
  {
    to    => $env_rcpt, # or @env_rcpts
    from => $env_sender,
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
  pass => ‘wishiwereanoscarmeyerweiner’,
});

$sender->send(
  $email,
  {
    to    => $env_rcpt, # or @env_rcpts
    from => $env_sender,
  }
my $sender = Email::Sender::SMTP->new({
  host => ‘sir-mx-a-lot.plusplus.com’,
  user => ‘rjbs’,
  pass => ‘wishiwereanoscarmeyerweiner’,
});

$sender->send(
  $email,
  {
    to    => $env_rcpt, # or @env_rcpts
    from => $env_sender,
  }
);
Email::Sender::Simple->send(
  $email,
  {
     to   => $recipient,
     from => $sender,
  },
);
Email::Sender::Simple->send(
  $email,
  {
     to   => $recipient,
     from => $sender,
  },
);


$ EMAIL_SENDER=SQLite ./your-program
Filtering Mail
Mail::Audit
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $mail = Mail::Audit->new;
my $mail = Mail::Audit->new;
my $mail = Mail::Audit->new;

$mail->ignore if $mail->from_daemon;
my $mail = Mail::Audit->new;

$mail->ignore if $mail->from_daemon;
my $mail = Mail::Audit->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
my $mail = Mail::Audit->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
  if $mail->subject =~ /sorry/i;
my $mail = Mail::Audit->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
  if $mail->subject =~ /sorry/i;
my $mail = Mail::Audit->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
  if $mail->subject =~ /sorry/i;

$mail->reject if $mail->from =~ /laura/i;
my $mail = Mail::Audit->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
  if $mail->subject =~ /sorry/i;

$mail->reject if $mail->from =~ /laura/i;
my $mail = Mail::Audit->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
  if $mail->subject =~ /sorry/i;

$mail->reject if $mail->from =~ /laura/i;

$mail->accept;
Email::Filter
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $mail = Email::Filter->new;
my $mail = Email::Filter->new;
my $mail = Email::Filter->new;

$mail->ignore if $mail->from_daemon;
my $mail = Email::Filter->new;

$mail->ignore if $mail->from_daemon;
my $mail = Email::Filter->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
my $mail = Email::Filter->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
  if $mail->subject =~ /sorry/i;
my $mail = Email::Filter->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
  if $mail->subject =~ /sorry/i;
my $mail = Email::Filter->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
  if $mail->subject =~ /sorry/i;

$mail->reject if $mail->from =~ /laura/i;
my $mail = Email::Filter->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
  if $mail->subject =~ /sorry/i;

$mail->reject if $mail->from =~ /laura/i;
my $mail = Email::Filter->new;

$mail->ignore if $mail->from_daemon;

$mail->accept(‘apologies’)
  if $mail->subject =~ /sorry/i;

$mail->reject if $mail->from =~ /laura/i;

$mail->accept;
key differences
key differences

Mail::Audit does more
key differences

Mail::Audit does more
Mail::Audit is > 4x the size
key differences

Mail::Audit does more
Mail::Audit is > 4x the size
Mail::Audit is totally insane
key differences

Mail::Audit does more
Mail::Audit is > 4x the size
Mail::Audit is totally insane
Mail::Audit is better tested
Mail::Procmail
Mail::Procmail

It’s like Mail::Audit
Mail::Procmail

It’s like Mail::Audit
but exports a bunch of subs
Mail::Procmail

It’s like Mail::Audit
but exports a bunch of subs
can be made into a E::F plugin
Mail::Procmail

It’s like Mail::Audit
but exports a bunch of subs
can be made into a E::F plugin
built-in logging
Mail::Sort
Mail::Sort

It’s like Mail::Audit
Mail::Sort

It’s like Mail::Audit
but has lots more methods
Mail::Sort

It’s like Mail::Audit
but has lots more methods
mostly for common matches
Mail::Sort

It’s like Mail::Audit
but has lots more methods
mostly for common matches
could be some E::F plugins
Email Addresses
HATE!!
Mail::Address

Email::Address
Mail::Address

Email::Address
Mail::Message
   ::Field::
  Address
Email::Valid
address is well-formed    domain actually exists

domain name is valid      some per-domain rules

domain is fqdn in a tld   some fudging allowed
Cool Stuff
Email::Stuff
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
Email::Stuff
Email::Stuff
  ->from('Principal Skinner <seymore@se.edu>')
Email::Stuff
  ->from('Principal Skinner <seymore@se.edu>')
  ->to('rjbs@cpan.org')
Email::Stuff
  ->from('Principal Skinner <seymore@se.edu>')
  ->to('rjbs@cpan.org')
  ->text_body(“Please see me after class.”)
Email::Stuff
  ->from('Principal Skinner <seymore@se.edu>')
  ->to('rjbs@cpan.org')
  ->text_body(“Please see me after class.”)
  ->header(Keywords => “trouble”)
Email::Stuff
  ->from('Principal Skinner <seymore@se.edu>')
  ->to('rjbs@cpan.org')
  ->text_body(“Please see me after class.”)
  ->header(Keywords => “trouble”)
  ->header(Keywords => “deep”)
Email::Stuff
  ->from('Principal Skinner <seymore@se.edu>')
  ->to('rjbs@cpan.org')
  ->text_body(“Please see me after class.”)
  ->header(Keywords => “trouble”)
  ->header(Keywords => “deep”)
  ->attach(
Email::Stuff
  ->from('Principal Skinner <seymore@se.edu>')
  ->to('rjbs@cpan.org')
  ->text_body(“Please see me after class.”)
  ->header(Keywords => “trouble”)
  ->header(Keywords => “deep”)
  ->attach(
    slurp(‘1099.pdf’),
Email::Stuff
  ->from('Principal Skinner <seymore@se.edu>')
  ->to('rjbs@cpan.org')
  ->text_body(“Please see me after class.”)
  ->header(Keywords => “trouble”)
  ->header(Keywords => “deep”)
  ->attach(
    slurp(‘1099.pdf’),
    filename => 'dead_bunbun_proof.gif')
Email::Stuff
  ->from('Principal Skinner <seymore@se.edu>')
  ->to('rjbs@cpan.org')
  ->text_body(“Please see me after class.”)
  ->header(Keywords => “trouble”)
  ->header(Keywords => “deep”)
  ->attach(
    slurp(‘1099.pdf’),
    filename => 'dead_bunbun_proof.gif')
  ->send;
HTML Email
(yeah, I know)
Email::MIME
::CreateHTML
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
use Email::MIME::CreateHTML;
use Email::MIME::CreateHTML;
my $email = Email::MIME->create_html(
use Email::MIME::CreateHTML;
my $email = Email::MIME->create_html(
  header => [
use Email::MIME::CreateHTML;
my $email = Email::MIME->create_html(
  header => [
    to      => ‘mom@aol.com’,
use Email::MIME::CreateHTML;
my $email = Email::MIME->create_html(
  header => [
    to      => ‘mom@aol.com’,
    from    => ‘rjbs@cpan.org’,
use Email::MIME::CreateHTML;
my $email = Email::MIME->create_html(
  header => [
    to      => ‘mom@aol.com’,
    from    => ‘rjbs@cpan.org’,
    subject => ‘Happy Birthday!’,
use Email::MIME::CreateHTML;
my $email = Email::MIME->create_html(
  header => [
    to      => ‘mom@aol.com’,
    from    => ‘rjbs@cpan.org’,
    subject => ‘Happy Birthday!’,
  ],
use Email::MIME::CreateHTML;
my $email = Email::MIME->create_html(
  header => [
    to      => ‘mom@aol.com’,
    from    => ‘rjbs@cpan.org’,
    subject => ‘Happy Birthday!’,
  ],
  body   => $html,
use Email::MIME::CreateHTML;
my $email = Email::MIME->create_html(
   header => [
     to      => ‘mom@aol.com’,
     from    => ‘rjbs@cpan.org’,
     subject => ‘Happy Birthday!’,
   ],
   body   => $html,
);
use Email::MIME::CreateHTML;
my $email = Email::MIME->create_html(
   header => [
     to      => ‘mom@aol.com’,
     from    => ‘rjbs@cpan.org’,
     subject => ‘Happy Birthday!’,
   ],
   body      => $html,
   text_body => $text,
);
my $markdown = slurp(STDIN);

use Email::MIME::CreateHTML;
my $email = Email::MIME->create_html(
   header => [
     to      => ‘mom@aol.com’,
     from    => ‘rjbs@cpan.org’,
     subject => ‘Happy Birthday!’,
   ],
   body      => markdown($markdown),
   text_body => $markdown,
);
use Email::StripMIME qw(strip_mime);

my $stripped_email = Email::MIME->new(
  strip_mime($email->as_string)
);
Sifting Through
  MIME Parts
Email::MIME::XPath
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
use Email::MIME::XPath;
use Email::MIME::XPath;
use Email::MIME::XPath;

my ($part) = $email->xpath_findnodes(“//plain”);
use Email::MIME::XPath;

my ($part) = $email->xpath_findnodes(“//plain”);
use Email::MIME::XPath;

my ($part) = $email->xpath_findnodes(“//plain”);

my @images = $email->xpath_findnodes(
use Email::MIME::XPath;

my ($part) = $email->xpath_findnodes(“//plain”);

my @images = $email->xpath_findnodes(
  “//png|//jpeg|//gif”
use Email::MIME::XPath;

my ($part) = $email->xpath_findnodes(“//plain”);

my @images = $email->xpath_findnodes(
  “//png|//jpeg|//gif”
);
use Email::MIME::XPath;

my ($part) = $email->xpath_findnodes(“//plain”);

my @images = $email->xpath_findnodes(
  “//png|//jpeg|//gif”
);
use Email::MIME::XPath;

my ($part) = $email->xpath_findnodes(“//plain”);

my @images = $email->xpath_findnodes(
  “//png|//jpeg|//gif”
);

my $address = $part->xpath_address;
use Email::MIME::XPath;

my ($part) = $email->xpath_findnodes(“//plain”);

my @images = $email->xpath_findnodes(
  “//png|//jpeg|//gif”
);

my $address = $part->xpath_address;
die “error in part $address!”;
Sending Signed Mail
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
my $gpg = Mail::GPG->new(
my $gpg = Mail::GPG->new(
  default_key_id => ‘12345678’,
my $gpg = Mail::GPG->new(
  default_key_id => ‘12345678’,
;
my $gpg = Mail::GPG->new(
  default_key_id => ‘12345678’,
;
my $gpg = Mail::GPG->new(
  default_key_id => ‘12345678’,
;

my $signed_entity = $gpg->mime_sign(
my $gpg = Mail::GPG->new(
  default_key_id => ‘12345678’,
;

my $signed_entity = $gpg->mime_sign(
  entity     => $entity,
my $gpg = Mail::GPG->new(
  default_key_id => ‘12345678’,
;

my $signed_entity = $gpg->mime_sign(
  entity     => $entity,
);
Managing Your Mail
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
addressbook = App::Addex::AddressBook::Apple
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin

[App::Addex::Output::Mutt]
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin

[App::Addex::Output::Mutt]
filename = mutt/alias-abook
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin

[App::Addex::Output::Mutt]
filename = mutt/alias-abook
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin

[App::Addex::Output::Mutt]
filename = mutt/alias-abook

[App::Addex::Output::Procmail]
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin

[App::Addex::Output::Mutt]
filename = mutt/alias-abook

[App::Addex::Output::Procmail]
filename = procmail/friends.rc
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin

[App::Addex::Output::Mutt]
filename = mutt/alias-abook

[App::Addex::Output::Procmail]
filename = procmail/friends.rc
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin

[App::Addex::Output::Mutt]
filename = mutt/alias-abook

[App::Addex::Output::Procmail]
filename = procmail/friends.rc

[App::Addex::Output::SpamAssassin]
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin

[App::Addex::Output::Mutt]
filename = mutt/alias-abook

[App::Addex::Output::Procmail]
filename = procmail/friends.rc

[App::Addex::Output::SpamAssassin]
filename = spamassassin/whitelists-abook
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin

[App::Addex::Output::Mutt]
filename = mutt/alias-abook

[App::Addex::Output::Procmail]
filename = procmail/friends.rc

[App::Addex::Output::SpamAssassin]
filename = spamassassin/whitelists-abook
addressbook = App::Addex::AddressBook::Apple
output = App::Addex::Output::Mutt
output = App::Addex::Output::Procmail
output = App::Addex::Output::SpamAssassin

[App::Addex::Output::Mutt]
filename = mutt/alias-abook

[App::Addex::Output::Procmail]
filename = procmail/friends.rc

[App::Addex::Output::SpamAssassin]
filename = spamassassin/whitelists-abook
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
alias mollymillions molly@bama-online.com (Molly Millions)
alias mollymillions-home molly@bama-online.com (Molly
Millions)
alias mollymillions-work mm@solo.com (Molly Millions)
alias mollymillions-work-1 s.shears@bodymiraculous.com (Molly
Millions)
alias mollymillions molly@bama-online.com (Molly Millions)
 alias mollymillions-home molly@bama-online.com (Molly
 Millions)
 alias mollymillions-work mm@solo.com (Molly Millions)
 alias mollymillions-work-1 s.shears@bodymiraculous.com (Molly
 Millions)



mailboxes =friends.molly
alias mollymillions molly@bama-online.com (Molly Millions)
 alias mollymillions-home molly@bama-online.com (Molly
 Millions)
 alias mollymillions-work mm@solo.com (Molly Millions)
 alias mollymillions-work-1 s.shears@bodymiraculous.com (Molly
 Millions)



mailboxes =friends.molly



save-hook ~fmolly@bama-online.com =friends.molly
save-hook ~fmm@solo.com =friends.molly
save-hook ~fs.shears@bodymiraculous.com =friends.molly
alias mollymillions molly@bama-online.com (Molly Millions)
 alias mollymillions-home molly@bama-online.com (Molly
 Millions)
 alias mollymillions-work mm@solo.com (Molly Millions)
 alias mollymillions-work-1 s.shears@bodymiraculous.com (Molly
 Millions)



mailboxes =friends.molly



save-hook ~fmolly@bama-online.com =friends.molly
save-hook ~fmm@solo.com =friends.molly
save-hook ~fs.shears@bodymiraculous.com =friends.molly



send-hook ~tmolly@bama-online.com set signature=quot;~/.sig/ninjaquot;
send-hook ~tmm@solo.com set signature=quot;~/.sig/ninjaquot;
send-hook ~ts.shears@bodymiraculous.com set signature=quot;~/.sig/
ninjaquot;
How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!
:0
* From:.*molly@bama-online.com
.friends.molly/

:0
* From:.*mm@solo.com
.friends.molly/

:0
* From:.*s.shears@bodymiraculous.com
.friends.molly/
:0
* From:.*molly@bama-online.com
.friends.molly/

:0
* From:.*mm@solo.com
.friends.molly/

:0
* From:.*s.shears@bodymiraculous.com
.friends.molly/




whitelist_from molly@bama-online.com
whitelist_from mm@solo.com
whitelist_from s.shears@bodymiraculous.com
The Future
Email::Corpus
Email::Corpus::Email
Email::Corpus::Addr
Email::KB::Headers
Metadata Plugin
Bounce Classifier
pep@perl.org
http://emailproject.perl.org/
Thank
 You!
1 of 473

More Related Content

What's hot(20)

Intoduction to php  restful web serviceIntoduction to php  restful web service
Intoduction to php restful web service
baabtra.com - No. 1 supplier of quality freshers2K views
Working with Groovy CollectionsWorking with Groovy Collections
Working with Groovy Collections
Ted Vinke620 views
Exch test-mail flowExch test-mail flow
Exch test-mail flow
Tzahi Kolber18 views
Build PHP Search EngineBuild PHP Search Engine
Build PHP Search Engine
Kiril Iliev3.9K views
ABV_fastcontactABV_fastcontact
ABV_fastcontact
arjun rao563 views
To infinity and beyondTo infinity and beyond
To infinity and beyond
clintongormley2.4K views
The effective use of Django ORMThe effective use of Django ORM
The effective use of Django ORM
Yaroslav Muravskyi3K views
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation Framework
Tyler Brock6.4K views
JQuery PresentationJQuery Presentation
JQuery Presentation
Sony Jain1.2K views
How to use MongoDB with CakePHPHow to use MongoDB with CakePHP
How to use MongoDB with CakePHP
ichikaway16.5K views
Round pegs and square holesRound pegs and square holes
Round pegs and square holes
Daniel Greenfeld5.9K views
Coffeescript a zCoffeescript a z
Coffeescript a z
Starbuildr506 views

Viewers also liked(20)

理解したつもりになるGit入門理解したつもりになるGit入門
理解したつもりになるGit入門
Yoshihiro Sasaki995 views
Asset Pipeline for PerlAsset Pipeline for Perl
Asset Pipeline for Perl
Yoshihiro Sasaki4.2K views
Google trends to_ircGoogle trends to_irc
Google trends to_irc
rarere883 views
Using DancerUsing Dancer
Using Dancer
Yoshihiro Sasaki5.3K views
Use CartonUse Carton
Use Carton
Yoshihiro Sasaki1.9K views
テーマ「最適化」テーマ「最適化」
テーマ「最適化」
technocat918 views
Takao.mt 2013Takao.mt 2013
Takao.mt 2013
moznion690 views
YAPC::AsiaとHokkaido.pmYAPC::AsiaとHokkaido.pm
YAPC::AsiaとHokkaido.pm
Yoshihiro Sasaki1.5K views
Currying in perlCurrying in perl
Currying in perl
Masahiro Honma3.1K views
PHPカンファレンス北海道_20160416PHPカンファレンス北海道_20160416
PHPカンファレンス北海道_20160416
Yoshihiro Sasaki1.1K views
Plack::Request with EncodingPlack::Request with Encoding
Plack::Request with Encoding
moznion1.5K views
YAPCレポートの舞台裏YAPCレポートの舞台裏
YAPCレポートの舞台裏
Masahiro Honma1.6K views
CPAN/便利モジュールCPAN/便利モジュール
CPAN/便利モジュール
Yoshihiro Sasaki1.8K views
変数、リファレンス変数、リファレンス
変数、リファレンス
charsbar1.8K views

Similar to How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!

Sending email with perlSending email with perl
Sending email with perlapeiron
1.2K views55 slides
dfhdfdfhdf
dfhdfguest635119
465 views4 slides

Similar to How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!(20)

Sending email with perlSending email with perl
Sending email with perl
apeiron1.2K views
dfhdfdfhdf
dfhdf
guest635119465 views
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden172 views
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
Dave Cross32.3K views
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
Ismail Mukiibi3.9K views
XML::Writer::SimpleXML::Writer::Simple
XML::Writer::Simple
Alberto Simões1.4K views
06 Php Mysql Connect Query06 Php Mysql Connect Query
06 Php Mysql Connect Query
Geshan Manandhar1.4K views
wget.plwget.pl
wget.pl
Yasuhiro Onishi1.2K views
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden1.1K views
Send emailSend email
Send email
Joselito Catanes3.9K views
Php.docxPhp.docx
Php.docx
CHMuhammadZohaibZafa115 views
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
Tatsuhiko Miyagawa4.9K views
Drupal Development (Part 2)Drupal Development (Part 2)
Drupal Development (Part 2)
Jeff Eaton2.1K views

More from Ricardo Signes(11)

Perl 5: Today, Tomorrow, and ChristmasPerl 5: Today, Tomorrow, and Christmas
Perl 5: Today, Tomorrow, and Christmas
Ricardo Signes1.7K views
What's New in Perl?  v5.10 - v5.16What's New in Perl?  v5.10 - v5.16
What's New in Perl? v5.10 - v5.16
Ricardo Signes2.4K views
Perl 5.14 for PragmatistsPerl 5.14 for Pragmatists
Perl 5.14 for Pragmatists
Ricardo Signes2.2K views
Perl 5.12 for Everyday UsePerl 5.12 for Everyday Use
Perl 5.12 for Everyday Use
Ricardo Signes1K views
i &lt;3 emaili &lt;3 email
i &lt;3 email
Ricardo Signes1.1K views
Dist::ZillaDist::Zilla
Dist::Zilla
Ricardo Signes2.5K views

How I Learned to Stop Worrying and Love Email::: The 2007 PEP Talk!!