【发布时间】:2011-03-16 06:22:24
【问题描述】:
我想将 Net::SMTP 与动态 socks 代理一起使用。 IO::Socket::Socks 知道 socks 但它应该如何与 net::smtp 一起使用?
【问题讨论】:
我想将 Net::SMTP 与动态 socks 代理一起使用。 IO::Socket::Socks 知道 socks 但它应该如何与 net::smtp 一起使用?
【问题讨论】:
我想通了,但它包括可能适用于或可能不适用于未来版本的 Net::SMTP 的 hack:
use Net::SMTP;
use Net::SOCKS;
my $socks = new Net::SOCKS(socks_addr=>$shost,socks_port=>$sport, protocol_version=>5) or die $!;
my $socksfd = $socks->connect(peer_addr=>$smtp_server,peer_port=>25);
if(!$socksfd){
die "Connection to SOCKS failed";
}
my $smtp = Net::SMTP->new_from_fd($socksfd->fileno, 'r+' ) or die $!;
#HACK: there is "220 host.domain.net" line we must read otherwise Net::SMTP would not work!
$smtp->getline();
$smtp->hello("localhost") or die $smtp->message();
#from here Net::SMTP business as usual...
【讨论】: