#!/usr/bin/perl use strict; use warnings; use Net::SMTP; my $mailhost = 'smtp.mydomain.com'; my $from = 'me@mydomain.com'; my @recipients = split '\s+|,|;', 'joe@domain.com,larry@otherdomain.com'; my $subject = 'Regarding your widget purchase'; my $msg =<<"END_MSG"; Hello, Good Sir! Would you like a free cookie with your orange juice? My hovercraft is full of eels! Please remember to wear a sweater when crossing the street. Regards, Mortimer J. Paulinskil END_MSG my $status = eval { my $smtp = Net::SMTP->new($mailhost, Timeout => 10, ); $smtp->mail($from); $smtp->recipient( @recipients, { Notify => ['FAILURE','DELAY'], SkipBad => 1 } ); $smtp->data("Subject: $subject\n\n$msg"); $smtp->quit(); } ? "MESSAGE SENT" : "Error sending message! [ $! ]\n"; print $status;