#!/usr/bin/perl use 5.008; use strict; use warnings; use constant SENDMAIL => '/usr/sbin/sendmail'; my $from = 'foo@bar.example'; my $to = 'blubb@boing.example'; my $subject = 'Some subject'; my $body = "The message you want to send\n"; open my $mail, '|-', SENDMAIL, $to or die "Couldn't spawn sendmail: $!\n"; print $mail <