Last active
December 3, 2017 19:14
-
-
Save jkeenan/22e16ca0b608d9fff043070b4944e658 to your computer and use it in GitHub Desktop.
Send an email on a system where 'sendmail' is running
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use 5.12.0; | |
use Email::Sender::Simple qw(sendmail); | |
use Email::Simple; | |
use Email::Simple::Creator; | |
my $instructions = | |
'http://search.cpan.org/~rjbs/Email-Sender-1.300031/lib/Email/Sender/Manual/QuickStart.pm'; | |
my $body = <<EOF; | |
This message is short, but at least it's cheap. | |
It's adapted directly from $instructions. | |
EOF | |
my $email = Email::Simple->create( | |
header => [ | |
To => q|"James E Keenan" <[email protected]>|, | |
# Don't try to send me mail at thenceforward.net; use pobox.com address | |
From => q|"Jim Keenan's Linode" <[email protected]>|, | |
Subject => q|Email via Email::Simple and Email::Sender::Simple|, | |
], | |
body => $body, | |
); | |
{ | |
local $@; | |
eval { | |
sendmail($email); | |
}; | |
if ($@) { say "Problem: <$@>"; } | |
else { say "Finished"; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment