Here is a simple custom emailing script using Perl. You need to install Mail::Sendmail module from CPAN to get it to work. You also need to change the values of $mailhost and $from field values.
Here is a typical usage of this program.
#!/usr/bin/perl
# Send emails via this platform independent module
use Mail::Sendmail;
main();
sub main {
my ($to, $subject, $message) = @ARGV;
send_email($to, $subject, $message);
}
# Sends email using Mail::Sendmail module
sub send_email {
my ($to, $subject, $message) = @_;
my ($mailhost, $from, %mail, @to);
$mailhost = "smtp.mydomain.com";
$from = "itm_alerts\@mydomain.com";
%mail = (
Smtp => $mailhost,
From => $from,
To => $to,
Subject => $subject,
Message => $message,
);
sendmail(%mail);
}
Hope you find it useful.
Tuesday, April 29, 2008
Sample Emailing Script
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment