FFSparky has asked for the wisdom of the Perl Monks concerning the following question:

Oh Wise Ones,

I've somehow managed to mess up my PERL environment by i believe installing a newer module. The issue I am fighting is with sending SMTP emails. Where running the same script on one server works and on another it fails.

With debug enabled the working server shows:

 Net::SMTP>>> Net::SMTP(2.31)
 Net::SMTP>>> Net::Cmd(2.29)
 Net::SMTP>>> Exporter(5.67)
 Net::SMTP>>> IO::Socket::INET(1.31)
 Net::SMTP>>> IO::Socket(1.32)
 Net::SMTP>>> IO::Handle(1.31)
 Net::SMTP=GLOB(0x1d2294c)<<< 220 mailhost.domain.com Microsoft ESMTP MAIL Service ready at Wed, 20 May 2015 08:43:09 -0500

Where on the server where I updated modules it shows:

 Net::SMTP>>> Net::SMTP(3.06)
 Net::SMTP>>> Net::Cmd(3.06)
 Net::SMTP>>> Exporter(5.67)
 Net::SMTP>>> IO::Socket::INET6(2.69)
 Net::SMTP>>> IO::Socket(1.32)
 Net::SMTP>>> IO::Handle(1.31)
 Net::SMTP: Net::Cmd::_is_closed(): unexpected EOF on command channel: at C:/Dev_Tools/PERL_32Bit/perl/site/lib/Email/Sender/Transport/SMTP.pm line 10 6.

To the best of my debugging abilities I'm thinking the issue is the new modules is trying to use IPV6:

Net::SMTP>>> IO::Socket::INET6(2.69)

Is there a simple way I can force it to instead use IPV4 ?

Thanks in Advance!

Replies are listed 'Best First'.
Re: Net::SMTP assistance
by Anonymous Monk on May 20, 2015 at 18:12 UTC

    The manpage suggests specifying: Domain => AF_INET. This changes how this is handled in the DNS lookup when both IPv6 and IPv4 records exist.

    However this needs to be disambiguated in the Net::SMTP call, prior to IO::Socket::INET being called. This may require changing the host wide resolver behavior to prefer INET4 records to AAAA records, or specifying perl module dns lookup to return A records only. Partial answer to investigate why this new behavior.

    In addition to the key-value pairs accepted by IO::Socket, + "IO::Socket::INET6" provides. Domain Address family AF_INET | AF_I +NET6 | AF_UNSPEC (default)
    If "Domain" is not given, AF_UNSPEC is assumed, that is, bo +th AF_INET and AF_INET6 will be both considered when resolving DNS n +ames. AF_INET6 is prioritary.
    (Concrete to IPv4 protocol) $sock = IO::Socket::INET6->new(PeerAddr => 'www.perl.org +', PeerPort => 'http(80)', Domain => AF_INET , Proto => 'tcp');
      See also: http://www.perlmonks.org/?node_id=948946

      Is it possible to upgrade Net::SMTP to use IO::Socket::IP instead?

      http://code.activestate.com/lists/perl5-porters/189012/

      In the mean time the work around seems to change the global resolve order, use a non IPV6 DNS server for host resolution or to delete the INET6 module on the Perl install. It will get more elegant with Socket::IP according to ActiveState link above. If you don't use IPV6 what about just turning it off on your server desktop, is that allowed or required in your site policy? Might ask your sysadmin.

        Thanks for your thoughts !!

        I learned a lesson late yesterday. As I have made an official switch from Active State to Strawberry Perl I was going through the usual motions of installing packages I thought I needed. Actually Strawberry has more so after a more careful review and only installing those that were not included, my problem is gone!

        I've made a not to not update any module that's already included in the code install going forward. If I need a more current module, I will instead look into updating the core PERL binaries as well.

      Similar issue reported:
      • http://www.nntp.perl.org/group/perl.ldap/2014/04/msg3761.html
      • https://rt.cpan.org/Public/Bug/Display.html?id=9312

      Seems compatibility of module releases in the IO::Socket::INET calls. While possible to rename INET6 module file, not suggested as fix in case of Perl apps requiring the IPv6 resolver. Could break something.. Next idea?