Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Mail with Perl

by Anonymous Monk
on Nov 02, 2004 at 08:43 UTC ( #404532=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How can u use ur perl script to mail to a user?

Replies are listed 'Best First'.
Re: Mail with Perl
by borisz (Canon) on Nov 02, 2004 at 08:54 UTC
Re: Mail with Perl
by davorg (Chancellor) on Nov 02, 2004 at 09:52 UTC
Re: Mail with Perl
by reneeb (Chaplain) on Nov 02, 2004 at 09:46 UTC
Re: Mail with Perl
by edan (Curate) on Nov 02, 2004 at 10:16 UTC

    Since nobody recommended it yet, we use Mail::Sendmail and it does the job quite nicely. It also purports to be platform-independent.

    --
    edan

Re: Mail with Perl
by pingo (Hermit) on Nov 02, 2004 at 10:18 UTC
    If you want to send multipart mails, I would recommend MIME::Lite.
Re: Mail with Perl
by TedPride (Priest) on Nov 02, 2004 at 12:16 UTC
    Unless I made a mistake somewhere, the following should work fine:
    use strict; use Net::SMTP; my $message = join('', <DATA>); my %hash = ( 'Host' => '123.456.789.012', # Mail server address 'From' => 'me@domain.com', 'Reply-To' => 'me@domain.com', 'To' => 'them@domain.com', 'Subject' => 'This is my email subject', 'Message' => \$message, ); mailer(\%hash); sub mailer { my $r = shift; print ("From: $r->{'From'}\n" . "To: $r->{'To'}\n" . "Reply-To: $r->{'Reply-To'}\n" . "Subject: $r->{'Subject'}\n\n" . ${$r->{'Message'}}); } __DATA__ Welcome to my email! This is the message to be mailed... -TedPride
    This is a much simplified version of an email script I use to send mailings through my SMTP. I would have tested it before posting, but the SMTP is down atm.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2021-01-27 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?