#!/usr/local/bin/perl -w use strict; use warnings; use LWP::UserAgent; use JSON qw(to_json); my $text = join "", <>; if( !length $text ) { exit 0; } my $api_key = "abcdefghi0123456789"; my $from = 'from@email-address.com'; my $to = 'to@email-address.com'; my $ua = LWP::UserAgent->new(); my $resp = $ua->post( "https://mandrillapp.com/api/1.0/" . "messages/send.json", Content => to_json( { key => $api_key, message => { text => $text, subject => $text, from_email => $from, to => [ { email => $to } ], } } ), ); if( $resp->is_error() ) { die "Sending mail failed: ", $resp->message(); }