Over a million developers have joined DZone.

Tiny Email-to-twitter Daemon Source From Http://colo.doxpara.com/etweet.pl

// Dan Kaminsky (twitter.com/dakami) Tiny email-to-twitter daemon source from http://colo.doxpara.com/etweet.pl

use Carp;
  use Net::SMTP::Server;
  use Net::SMTP::Server::Client;
  use Net::Twitter;

  $server = new Net::SMTP::Server('localhost', 25) ||
    croak("Unable to handle client connection: $!\n");

  while($conn = $server->accept()) {
    # We can perform all sorts of checks here for spammers, ACLs,
    # and other useful stuff to check on a connection.

    # Handle the client's connection and spawn off a new parser.
    # This can/should be a fork() or a new thread,
    # but for simplicity...
    my $client = new Net::SMTP::Server::Client($conn) ||
        croak("Unable to handle client connection: $!\n");

    # Process the client.  This command will block until
    # the connecting client completes the SMTP transaction.
    $client->process || next;

    my $msg = $client->{MSG};
    my @tmp = split(' ', $msg);
    my $username = shift @tmp;
    my $password = shift @tmp;
    my $msg = join(' ', @tmp);
    print "user: $username \n pass: $password \n $msg \n";

  my $nt = Net::Twitter->new(
      traits   => [qw/API::REST/],
      username => $username,
      password => $password



Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}