使用别的邮件系统有诸多限制,
不如用linux系统本机的邮件功能;
#!/usr/bin/perl
##
# Test linux mail
##
use warnings;
use strict;
use Mail::Mailer;
use Socket;
my $mail_subject = "test mail";
my @daily_mail_content = "test is ok!\n";
&mailer_send_mail($mail_subject, \@daily_mail_content);
sub mailer_send_mail {
my ($subject, $param) = @_;
my $message = join('',@$param);
my $host = `hostname`;
my $mail_host = 'root@'.$host;
my $from_address = $mail_host;
my $to_address = 'username@yyy.com';
my $mailer = Mail::Mailer->new("sendmail");
$mailer->open({From => $from_address,
To => $to_address,
Subject => $subject,
})
or die "Can't open : $!\n";
print $mailer $message;
$mailer->close();
}
阅读(1820) | 评论(0) | 转发(0) |