You can use Mail::Mailer this way:
my $mailer = new Mail::Mailer ( "smtp" );
$mailer->open( {
To => $email,
From => 'The Webmaster <webmaster@scripted.com>',
Subject => 'Web Site Feedback'
} );
print $mailer <<END_OF_MESSAGE;
Your message has been sent and someone should be responding to you
shortly. Thanks for taking the time to provide us with your feedback!
END_OF_MESSAGE
close $mailer;
When you create a Mail::Mailer object, you can specify whether you
want it to send the message one of three ways:
- mail
Mail::Mailer will search your system for mailx,
Mail, or mail in that order and
use the first one it finds (we didn't discuss
Mail, although on many systems
Mail and mail are the
same -- mail is simply a symlink to
Mail ).
- sendmail
Mail::Mailer will use sendmail to send mail.
- smtp
Mail::Mailer will use the Net::SMTP Perl module to send mail.
If you do not specify an argument when you create an object,
Mail::Mailer will search through each of these three options in order
and use the first one it finds When Mail::Mailer uses an external
mailer, it uses the fork and
exec technique to avoid passing arguments
through the shell.