我正在尝试使用带有身份验证的MIME::Lite
发送电子邮件。
这是我正在尝试的代码段:
#!/usr/bin/perl
use strict;
use DBI;
use lib '/theannealing.com/perl/';
use MIME::Lite;
use MIME::Base64;
use Authen::SASL;
my $recipient = 'recipient@email.com';
my $mailman = 'sender@email.com';
my $cc_recipient = 'ccrecipient@email.com';
my $subject = 'Subject';
my $email_message = "Message";
my ($user,$pass) = ("username","password");
MIME::Lite->send('smtp','smtp.server:port',AuthUser=>$user, AuthPass=>$pass);
my $email = new MIME::Lite(From => $mailman,To => $recipient,Cc => $cc_recipient,Subject => $subject,Data => "Data",Type => "multipart/mixed");
$email->attach(Type => 'TEXT', Data => "$email_message");
$email->send();
当我执行脚本时,收到此错误消息:
Cannot find a SASL Connection library at /usr/lib/perl5/5.8.8/Net/SMTP.pm line 143
我尝试搜索错误消息,找不到任何与MIME::Lite
有谁知道错误或产生错误信息的原因是什么?
<小时/> 更新的 使用mail()
函数通过php发送电子邮件可以在Web浏览器中正常工作,但无法在命令行中运行
答案 0 :(得分:2)
您需要重新安装Authen :: SASL - 它安装不正确。从命令行以root身份执行此操作:
cpan GBARR/Authen-SASL-2.15.tar.gz