use Net::SMTP_auth to auth the smtp server
应该说 Net::SMTP 的 auth 并不是很好,它是根据 SMTP 服务器返回的 AUTH 支持参数来进行下一步的 auth 行动。但是有时候 SMTP 会返回很多个 auth 类型如 LOGIN CRAM-MD5 PLAIN,但是你可能需要用 PLAIN 来进行验证。这时候 Net::SMTP_auth 会派上用场。
Net::SMTP_auth @ISA = qw(Net::SMTP); 唯一不同的是它比 Net::SMTP 的 auth 上多了一个参数。
Net::SMTP 的可能是这样 $smtp->auth($username, $password);
但是 Net::SMTP_auth 多了一个参数指定 auth 类型。$smtp->auth('PLAIN', $username, $password);
如果非得要用 Net::SMTP 来进行 AUTH PLAIN 的话也是可以的:
好象是这样子的。Have fun!
Net::SMTP_auth @ISA = qw(Net::SMTP); 唯一不同的是它比 Net::SMTP 的 auth 上多了一个参数。
Net::SMTP 的可能是这样 $smtp->auth($username, $password);
但是 Net::SMTP_auth 多了一个参数指定 auth 类型。$smtp->auth('PLAIN', $username, $password);
如果非得要用 Net::SMTP 来进行 AUTH PLAIN 的话也是可以的:
use MIME::Base64;
# after $stmp = Net::SMTP->new
$smtp->command('AUTH PLAIN')->response();
my $userpass = encode_base64("\000$username\000$password");$userpass =~ s/\n//g;
$smtp->command($userpass)->response();
好象是这样子的。Have fun!
0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home