Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

SMTP "auth" problem after upgrade

by soliplaya (Beadle)
on May 12, 2011 at 10:49 UTC ( [id://904354]=perlquestion: print w/replies, xml ) Need Help??

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

Hi brothers. A program of mine contains the following section :
... MIME::Lite->send( 'smtp' => $args->{'smtp'}, 'AuthUser' => $uid, 'AuthPass' => $args->{'smtppw'} ); ...
This has worked fine for a couple of years, under perl 5.8.8. This last week-end, the host was upgraded from Debian Linux "Etch" to "Lenny", and at the same time perl went from 5.8.8 to 5.10.0. As a result, the same program now crashes with the following error :

2011/05/12-11:40:25 error SMTP auth() command failed: 5.5.4 Syntax: AUTH mechanism

Does that ring a bell to anyone ? I tried to follow the chain of what happens, and track it down to this section of MIME::Lite :
my $smtp = MIME::Lite::SMTP->new( $hostname, %opts ) or Carp::croak "SMTP Failed to connect to mail server: $!\n"; # Possibly authenticate if ( defined $args{AuthUser} and defined $args{AuthPass} and !$args{NoAuth} ) { if ($smtp->supports('AUTH',500,["Command unknown: 'AUTH'"])) { $smtp->auth( $args{AuthUser}, $args{AuthPass} ) or die "SMTP auth() command failed: $!\n" . $smtp->message . "\n"; } else { die "SMTP auth() command not supported on $hostname\n"; } }
and gather that MIME::Lite::SMTP->new() itself boils down to a Net::SMTP->new(), but then I get hopelessly lost, because that is definitely wizard code from Graham Barr and such, leading further to Authen::SASL and lots of references to globs (or vice-versa, my head spins).

Anyway, my basic question is : this worked fine for years with perl 5.8.8, the mail server has not changed, my program has not changed, so any clue about what is happening here ?

Replies are listed 'Best First'.
Re: SMTP "auth" problem after upgrade
by Anonymous Monk on May 12, 2011 at 11:19 UTC
    Anyway, my basic question is : this worked fine for years with perl 5.8.8, the mail server has not changed, my program has not changed, so any clue about what is happening here?

    Something did actually change, probably a missing prerequisite, like say, some Authen::SASL module for some AUTH mechanism... the part of the error/debug trace you omitted

Re: SMTP "auth" problem after upgrade
by Khen1950fx (Canon) on May 12, 2011 at 15:36 UTC
    You may have to use Net::SMTP;
    #!/usr/bin/perl use strict; use warnings; use MIME::Lite; use Net::SMTP; my $host = 'host'; my $user = 'user'; my $pass = 'pass'; unless (defined 'NoAuth') { my $smtp = MIME::Lite->send( 'smtp', $host, AuthUser => $user, AuthPass => $pass, Debug => 1 ); } else { my $smtp = MIME::Lite->send( 'smtp', $host, NoAuth => 1, Debug => 1 ); }
      Apart from the fact that $smtp is scoped out of existence and Noauth being tested for defined looks like a tautology in this snippet, I would be inclined to factorise out the "unless" in such a situation where most of the lines of code in the two branches are identical, and use a tertiary operator instead :
      my $smtp = MIME::Lite->send('smtp', $host, defined( $something_else ) ? AuthUser => $user, AuthPass => $pass : Noauth => 1, Debug => 1 );

      One world, one people

Re: SMTP "auth" problem after upgrade
by sundialsvc4 (Abbot) on May 12, 2011 at 11:47 UTC

    /me nods...

    It does sound like a missing prerequisite ... that is to say, something that didn’t get updated (or perhaps, merely recompiled, if it is XS code and there was a library change).   Unfortunately, packages like that can go very “deep,” with a lot of dependencies.   The prereq lists in each package are not always perfect.

    I’d check the bug-report tickets on the packages at CPAN and, when you identify the problem, definitely open a new one.   (Even if the resolution is merely procedural, i.e. “recompile this,” it will “put it on the radar.”)

      Sorry for not coming back here earlier, I was kind of busy with other devotions.

      Anyway, this solved my problem :

      use Authen::SASL qw(Perl); use MIME::Lite;

      For me it works, without appearing to have any deleterious side-effects in how the program runs or how much time it takes.

      It would appear that something is amiss in at least the Debian Lenny packages for Authen::SASL::XS*. But my knowledge of such arcane things being what it is, I could not tell what, nor do I know exactly what to do about it for the benefit of the gentile multitude.

      P.S. I also tried to re-install the Authen::SASL::XS* packages using "perl -MCPAN" directly, but that did not solve the problem either. Which means I remain just as clueless.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://904354]
Approved by John M. Dlugosz
Front-paged by John M. Dlugosz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-26 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found