【问题标题】:Using socks5 proxy with Net::SMTP使用带有 Net::SMTP 的 socks5 代理
【发布时间】:2011-03-16 06:22:24
【问题描述】:

我想将 Net::SMTP 与动态 socks 代理一起使用。 IO::Socket::Socks 知道 socks 但它应该如何与 net::smtp 一起使用?

【问题讨论】:

    标签: perl smtp socks


    【解决方案1】:

    我想通了,但它包括可能适用于或可能不适用于未来版本的 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...
    

    【讨论】:

    • 你能帮我吗?如何使用 ssl/tls 实现它?
    猜你喜欢
    • 1970-01-01
    • 2014-08-06
    • 2018-07-28
    • 1970-01-01
    • 2013-01-05
    • 2021-03-11
    • 1970-01-01
    • 1970-01-01
    • 2012-02-11
    相关资源
    最近更新 更多