MIME::Lite 不支持 SMTP
MIME::Lite not working with SMTP
我已经使用 MIME::Lite
有一段时间了,可以毫无问题地发送到我的邮件列表,但最近决定使用 SMTP 身份验证,因为我听说它更适合电子邮件来源验证。
我无法让它工作。我检查并安装了 Net::SMTP
模块,据我所知 Mime::Lite
用于此。
有什么想法吗?
这是我的代码:
my $mailHost = 'mail.domain.com';
my $user = 'username';
my $pass = 'password';
my $html = 'someHTML';
my $text = 'someText';
use MIME::Lite;
MIME::Lite->send( 'smtp', $mailHost, AuthUser => $user, AuthPass => $pass );
my $msg = MIME::Lite->new(
From => 'Mailing list <list@domain.com>',
To => $email,
Subject => $subject,
Type => 'multipart/alternative'
);
$msg->attach(
Type => 'TEXT',
Data => $text
);
$msg->attach(
Type => 'text/html',
Data => $html
);
$msg->send();
我不推荐MIME::Lite。我并不孤单。当前documentation for the module表示:
WAIT!
MIME::Lite is not recommended by its current maintainer. There are a
number of alternatives, like Email::MIME or MIME::Entity and
Email::Sender, which you should probably use instead. MIME::Lite
continues to accrue weird bug reports, and it is not receiving a large
amount of refactoring due to the availability of better alternatives.
Please consider using something else.
我推荐 Email::Sender or Email::Stuffer。它们都支持 SMTP 身份验证。
但是,当然,这可能根本无法解决您的问题。如果问题出在您的 SMTP 配置上,那么此更改不会让您更接近。我建议询问系统管理员邮件日志保存在哪里,这样您就可以看到实际问题是什么。
我找到了解决方案。通过 SMTP 进行身份验证需要 NET::SMTP
。以下代码现在可用于使用 MIME::LITE
和 SMTP
发送电子邮件:
my $mailHost = 'domain.com';
my $user = 'username';
my $pass = 'password';
my $html = 'someHTML';
my $text = 'someText';
use MIME::Lite;
use Net::SMTP;
MIME::Lite->send( 'smtp', $mailHost, AuthUser => $user, AuthPass => $pass );
my $msg = MIME::Lite->new(
From => 'Mailing list <list@domain.com>',
To => $email,
Subject => $subject,
Type => 'multipart/alternative'
);
$msg->attach(
Type => 'TEXT',
Data => $text
);
$msg->attach(
Type => 'text/html',
Data => $html
);
$msg->send();
我已经使用 MIME::Lite
有一段时间了,可以毫无问题地发送到我的邮件列表,但最近决定使用 SMTP 身份验证,因为我听说它更适合电子邮件来源验证。
我无法让它工作。我检查并安装了 Net::SMTP
模块,据我所知 Mime::Lite
用于此。
有什么想法吗?
这是我的代码:
my $mailHost = 'mail.domain.com';
my $user = 'username';
my $pass = 'password';
my $html = 'someHTML';
my $text = 'someText';
use MIME::Lite;
MIME::Lite->send( 'smtp', $mailHost, AuthUser => $user, AuthPass => $pass );
my $msg = MIME::Lite->new(
From => 'Mailing list <list@domain.com>',
To => $email,
Subject => $subject,
Type => 'multipart/alternative'
);
$msg->attach(
Type => 'TEXT',
Data => $text
);
$msg->attach(
Type => 'text/html',
Data => $html
);
$msg->send();
我不推荐MIME::Lite。我并不孤单。当前documentation for the module表示:
WAIT!
MIME::Lite is not recommended by its current maintainer. There are a number of alternatives, like Email::MIME or MIME::Entity and Email::Sender, which you should probably use instead. MIME::Lite continues to accrue weird bug reports, and it is not receiving a large amount of refactoring due to the availability of better alternatives. Please consider using something else.
我推荐 Email::Sender or Email::Stuffer。它们都支持 SMTP 身份验证。
但是,当然,这可能根本无法解决您的问题。如果问题出在您的 SMTP 配置上,那么此更改不会让您更接近。我建议询问系统管理员邮件日志保存在哪里,这样您就可以看到实际问题是什么。
我找到了解决方案。通过 SMTP 进行身份验证需要 NET::SMTP
。以下代码现在可用于使用 MIME::LITE
和 SMTP
发送电子邮件:
my $mailHost = 'domain.com';
my $user = 'username';
my $pass = 'password';
my $html = 'someHTML';
my $text = 'someText';
use MIME::Lite;
use Net::SMTP;
MIME::Lite->send( 'smtp', $mailHost, AuthUser => $user, AuthPass => $pass );
my $msg = MIME::Lite->new(
From => 'Mailing list <list@domain.com>',
To => $email,
Subject => $subject,
Type => 'multipart/alternative'
);
$msg->attach(
Type => 'TEXT',
Data => $text
);
$msg->attach(
Type => 'text/html',
Data => $html
);
$msg->send();