mail::sender 使用中存在的问题
mail::sender 使用中存在的问题
最近测试mail::sender模块几种发送邮件的方法,却发现不同的方式之间存在差异.以下eg1:是使用MailFile方法,是可以正确发送到指定路径(大家可以测试下).但是在使用open的方式却无法得到SMTP server的响应.邮件信息不能正确发送,eg2.也仔细看了代码说明也查不出问题.请各位有空帮小弟测试下....
eg1:
use strict;
use Mail::Sender;
my $sender = new Mail::Sender {
smtp => 'smtp.tom.com',
from => 'leaon110@tom.com',
auth => 'LOGIN',
authid => 'enter your user ID',
authpwd => 'enter your pass word',
on_errors => undef,
} or die "Can't create the Mail::Sender object: $Mail::Sender::Error\n";
$sender->MailFile(
{to =>'enter your email address',
subject => 'bad man',
msg => "I'm sending you the list you wanted.",
file => './name.txt'}) or print $Mail::Sender::Error;
$sender ->Close();
====================================================
eg2:
se strict;
use Mail::Sender;
my $sender = new Mail::Sender {
smtp => 'smtp.tom.com',
from => 'leaon110@tom.com',
auth => 'LOGIN',
authid => 'enter your user ID',
authpwd => 'enter your pass word',
on_errors => undef,
} or die "Can't create the Mail::Sender object: $Mail::Sender::Error\n";
$sender->Open(
{
to =>'leaon110@tom.com',
cc =>'leaon110@tom.com',
subject => 'Sorry, I will come later.'
})
or die "Can't open the message: $sender->{'error_msg'}\n";
$sender->SendLineEnc("I'm sorry, but thanks to the lusers,I'll come at 10pm at best.");
$sender->SendLineEnc("\nHi, Jenda");
$sender ->Close() or die "Failed to send the message : $sender->{'error_msg'}\n";