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

I have a script that emails me details from a file. The script works fine in a 32-bit version of Activeperl, but does not run using a 64-bit version. It seems to crap out on this line:

$smtp->mail($email_from); # sender's address
  • Why would that ever be a case?
  • How can I fix this to work on either version?
  • use Net::SMTP; use Win32::EventLog; $summary = ''; $extra = ''; $begin_summary = 0; $data_file = "C:/Logs/myfile.log"; open(IN, $data_file) || die("Could not open file!"); @raw_data = <IN>; close(IN); for my $row (@raw_data) { if ( $row =~ /\s+Total\s+Copied\s+Skipped\s+Mismatch\s+FAILED\s+Ex +tras\s+/ ) { $begin_summary = 1; } if ( $begin_summary ) { $summary .= $row; } if ($row =~ /\s+Ended \: /) { #print "Exiting loop\n"; last; } } write_event(900, EVENTLOG_INFORMATION_TYPE, $summary); send_email("My Big Fat Notification - " . $ENV{COMPUTERNAME}, "$extra\ +n$summary"); sub send_email() { my ($subject, $body) = @_; my $email_from = 'fromster@frobot.com'; my $email_to = ('toster@frobot.com'); my $smtp = Net::SMTP->new('smtpserver.frobot.com'); # Connect to a +n SMTP server $smtp->mail($email_from); # sender's address $smtp->to($email_to); # Recipient's address $smtp->data(); # Start the mail # Send the header. $smtp->datasend("To: $email_to\n"); $smtp->datasend("From: $email_from\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("\n"); MORE CODE AFTER THIS...

    Replies are listed 'Best First'.
    Re: Mail - 32bit vs 64bit
    by marto (Cardinal) on Mar 22, 2017 at 13:35 UTC

      It dies with literally no error messages? Have you considered switching on debugging in Net::SMTP since you suspect it's related to this?

      Net::SMTP->new( Host => 'mailhost', Hello => 'my.mail.domain', Timeout => 30, Debug => 1, # <-- This );
    Re: Mail - 32bit vs 64bit
    by LanX (Saint) on Mar 22, 2017 at 14:10 UTC
      Did you install both Perl versions on the same system?

      If yes, did you care to separate lib and other paths?

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

        To explain a bit more... a 64-bit perl is not going to be happy if it tries to load a 32-bit compiled library. So: how do you select whether you're running the 32- or 64-bit perl? And are you sure that the correct libs are being loaded in both cases? Checking @INC would be a good idea.
    Re: Mail - 32bit vs 64bit
    by vrk (Chaplain) on Mar 22, 2017 at 17:02 UTC

      Which version of ActivePerl is this? I'm looking at Net/SMTP.pm from (64-bit) ActivePerl 5.18.2, and sub mail has a number of cases where it can carp(). Do you see any warnings? What does "crap out" mean in this case? Turning on Net::SMTP debugging as marto suggests might reveal whether the problem comes from argument processing in sub mail, from sending the MAIL command to the remote server or parsing the response from the remote server.