#!/usr/bin/perl
use strict;
use Net::SMTP;
use
Authen::SASL;
my $data;
my $NUM=0;
my
$mail_name;
my $name;
my $mail;
my $LogFile="message.txt"; 发送邮件内容
:如 我是邮件内容,我和别人不一样的地方 {<--name-->}
my $mail_name_file="list.txt";
发送邮件地址列表和 每封邮件需要替换的内容 如: 我们是要替换的内容
open (FILE,"$LogFile") or die "Can not
open $LogFile for reading : $!";
open (FILE1,"$mail_name_file") or die "Can
not open $LogFile for reading : $!";
my @message=
my
@mail_name=
sub sendmail{
my $message;
($name,$mail) =
@_;
$message=join('',@message);
$message =~ s/{<--name-->}/$name/;
#替换发送邮件内容需要替换的内容
# print $message;
print $mail;
my $from =
;
my $to = '$mail';
my $username =
;
my $passwd = '65432111111';
my $subject =
'Test Email';
my $smtp = Net::SMTP->new('mail.woyo.com');
$smtp->auth($username,$passwd) or die "Could not authenticate
$!";
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("From:$from\n");
$smtp->datasend("To:
$to\n");
#$smtp->datasend("Cc: $Cc\n");
$smtp->datasend("Subject:
$subject\n");
$smtp->datasend("This is a test perl email\nIt is
successfull");
$smtp->dataend();
$smtp->quit;
}
foreach $mail_name(@mail_name)
{
my @arr;
@arr =
split(/\s+/,$mail_name);
sendmail($arr[0],$arr[1])
}