PerlのNet::POP2モジュールを利用したメール受信のサンプルです。このスクリプトをcronに登録し、定期的にメールボックスを確認させて、何かあったらコマンドを実行。なんて用途に使えます。パスワードも平文でのっけているので、セキュリティ的な注意は必要かと思います。

#!/usr/bin/env perl

use Net::POP3;

sub getmail()
{
  my ($server, $user, $passwd, $delete) = @_;
  my @result;
  my $p = Net::POP3->new($server) or die "Couldn't connect to $server.";
  $p->login($user, $passwd);
  foreach $id (keys(%{$p->list()})) {
    push(@result, @{$p->get($id)});
    $p->delete($id) if ($delete);
  }
  $p->quit;
  return @result;
}

print &getmail('pop.example.com', 'example@example.com', 'mypassword');