Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Simplest module for sending email

by Hercynium (Hermit)
on Oct 11, 2007 at 19:34 UTC ( #644312=note: print w/ replies, xml ) Need Help??


in reply to Simplest module for sending email

Thanks! I think I've been suffering from CPAN-vertigo. So many modules for email makes this monkey dizzy sometimes.

For the curious, here's what I ended up with:

#!/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;

MIME::Lite would have been great, except that sendmail on that system is seriously broken :(

Thanks again!


Comment on Re: Simplest module for sending email
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://644312]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (18)
As of 2015-07-29 16:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (265 votes), past polls