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

OK. Here is the error message. I stepped through the code to get this. My source file is after that. Names have been changed to protect the guilty

This was working perfectly with the older versions of SMTP.pm which did not use Authen:SASL. If you change your mail server, username and password, it should work with the older smtp.pm, but not the newer version.
Net::SMTP::auth(/usr/share/perl/5.8/Net/SMTP.pm:114): 114: die "auth(username, password)" if not length $username; DB<2> n Net::SMTP::auth(/usr/share/perl/5.8/Net/SMTP.pm:115): 115: $sasl = Authen::SASL->new(mechanism=> $mechanisms, 116: callback => { user => $usernam +e, 117: pass => $passwor +d, 118: authname => $username, DB<2> n Net::SMTP::auth(/usr/share/perl/5.8/Net/SMTP.pm:124): 124: my $client = $sasl->client_new('smtp',${*$self}{'net_smtp_host'},0); DB<2> n Net::SMTP::auth(/usr/share/perl/5.8/Net/SMTP.pm:124): 124: my $client = $sasl->client_new('smtp',${*$self}{'net_smtp_host'},0); DB<2> n Unknown callback: 'authname'. (user|auth|language|pass) Authen::SASL::client_new('Authen::SASL=HASH(0x856fa78)', 'smtp' +, 'outgoing.verizon.net', 0) called at /usr/share/perl/5.8/Net/SMTP.pm l +ine 124 Net::SMTP::auth('Net::SMTP=GLOB(0x850980c)', 'nnigam', 'mypassw +ord') called at posturl.pl line 103 Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info.
My Source file
#!/usr/bin/perl ##################################################################### # File: posturl.pl # # Version: 1.0.0 # # For: Personal # # Language: Perl 5.004_04 # # Author: Neeraj C. Nigam # # Date: May 12, 2003 # # Purpose : # # Revision History: # ##################################################################### use strict; #use ncn::sfunc ; #use ncn::taps ; use Net::SMTP; my($par1,$par2) = (uc($ARGV[0]),$ARGV[1]) ; # Expects a slash at the +end if directory $par1 = $par1 || "AB"; $par2 = $par2 || "XXX"; my ($smtp); my ($mailSrc)="XXX"; my ($sndr)="Bill Gates"; my ($qryStr,$datLen); my (@aMain); my ($nmPar,$nmValue); my ($msgdat)=""; my ($web)=1; if ( $par1 eq "X" ) { $web=0; if ( $par2 ne "" ) { $mailSrc=$par2; } } open (LOG,">>log.txt"); print LOG "New Record\n"; # Reading from Web Site Begin if ( $web ) { $datLen=$ENV{'CONTENT_LENGTH'}; read (STDIN, $qryStr, $datLen); @aMain=split(/&/,$qryStr); print "Content-Type: text/html\n\n"; foreach (@aMain){ ($nmPar,$nmValue)=split(/=/,$_); $nmValue =~ tr/+/ /; $nmValue =~ s/%([\dA-Fa-f][\dA-Fa-f])/ pack ("C", hex($1))/eg; print "$nmPar = $nmValue<br>\n"; if ($msgdat eq ""){ $msgdat=$nmPar . "=" .$nmValue. "\n" ; } else { $msgdat=$msgdat . $nmPar . "=" .$nmValue. "\n" ; } #print "$nmValue<br>\n"; print LOG "$nmPar = $nmValue\n"; if ($nmPar eq "fEMail") { $mailSrc=$nmValue; } } print "<br><br>\n\n"; print $msgdat; # Read from Website End } else { $nmValue="Bill.Gates\@microsoft.com"; $msgdat="Email =" . $nmValue . "\n" ; $nmValue="Bill Gates"; $msgdat=$msgdat . "Name =" . $nmValue . "\n" ; $nmValue="Redmond, Washington"; $msgdat=$msgdat . "Add1 =" . $nmValue . "\n" ; $nmValue=""; $msgdat=$msgdat . "Add2 =" . $nmValue . "\n" ; $nmValue="Redmond"; $msgdat=$msgdat . "City =" . $nmValue . "\n" ; $nmValue="WA"; $msgdat=$msgdat . "State =" . $nmValue . "\n" ; $nmValue="00000-0000"; $msgdat=$msgdat . "Zip =" . $nmValue . "\n" ; $nmValue="000-000-0000"; $msgdat=$msgdat . "Phone =" . $nmValue . "\n" ; $nmValue="Mail"; $msgdat=$msgdat . "Contact by Email\n" ; $nmValue="Your dad asked me to contact you Are you interested"; $msgdat=$msgdat . "Msg =" . $nmValue . "\n" ; print LOG $msgdat; } #$smtp = Net::SMTP->new('smtpout.bellatlantic.net'); #mail host $smtp = Net::SMTP->new('outgoing.verizon.net',Debug=>1); #$smtp = Net::SMTP->new('outgoing.verizon.net'); if ($smtp eq ""){ print "Error connecting to Mail server\n"; print "Your message has not been sent\n"; die; } $smtp->auth('nnigam','password'); if ($mailSrc eq "XXX") { $smtp->mail('nnigam@verizon.net'); } else { $smtp->mail($mailSrc); } $smtp->to('pratibha@pntravels.com'); $smtp->data(); $smtp->datasend("Subject: WebFormData\n"); $smtp->datasend($msgdat); # Try to Add Env Info #my (@env_rep)=split(/,/,$query{'env_report'} || ''); #my ($env); #foreach $env (@env_rep) { # $smtp->datasend("$env: $ENV{$env}\n") or &smtperror; #} for (keys %ENV){ $smtp->datasend("$_: $ENV{$_}\n") or &smtperror; } $smtp->dataend(); $smtp->quit(); print "Your message has been sent\n"; print "<form method='get' action='/index.html'><br>"; print "<input type='submit' value='Press to Return'><br>"; print "</form>"; close(LOG);
--------------------

I recently upgraded by web server to debian 3.1 (Sarge) from degian 3.0. My apache, perl etc were also upgraded with the new install. Now my webserver mail form has stopped functioning pointing to a variable authname. I have located this in smtp.pm version 2.26. I originally had 2.15 I believe.

The new version of smtp.pm also seems to want Authen:SASL which was not being used. I installed Authen:SASL, but the error still persists. Looking at smtp.pm, I see the following section where authname appears to be the same as user. But still keep on getting the error when trying to authenticate to my verizon mail server to send the mail message. Any help would be greatly appreciated. I wrote the script to mail my messages, and can make it available if anyone wants to test it out.
if (ref($username) and UNIVERSAL::isa($username,'Authen::SASL')) { $sasl = $username; $sasl->mechanism($mechanisms); } else { die "auth(username, password)" if not length $username; $sasl = Authen::SASL->new(mechanism=> $mechanisms, callback => { user => $username, pass => $password, authname => $username, }); }

Replies are listed 'Best First'.
Re: SMTP Authen Error
by itub (Priest) on Jul 19, 2005 at 23:35 UTC
    Last time I had a similar problem was because I needed to use Net::SMTP_auth instead of Net::SMTP.
Re: SMTP Authen Error
by gellyfish (Monsignor) on Jul 19, 2005 at 18:21 UTC

    I think you are going to have to give us the actual text of the error so we can track it down.

    /J\

      I will have to wait until tomorrow to get the exact error as the system is at home, and I forgot to enable ssh on my router. It occurs on the line $smtp->auth... Before that everything is perfect.
      $smtp = Net::SMTP->new('outgoing.verizon.net',Debug=>1); if ($smtp eq ""){ print "Error connecting to Mail server\n"; print "Your message has not been sent\n"; die; } $smtp->auth('myuserid','Password');

        That just gives me:

        535 5.7.8 Bad username or password (Authentication failed).
        As I would have expected. I think it is likely that you are negotiating the wrong AUTH type or are missing a module that would allow the proper AUTH type. But we really do need to see the whole debug output.

        /J\

Re: SMTP Authen Error
by zentara (Cardinal) on Jul 19, 2005 at 18:42 UTC
    It would probably be enlightening to watch the actual network negotiations with something like tcpick

    I know the last time I messed with smtp_auth, the "real" errors were not making it thru to the perl script. But once I saw where the auth_server was stopping, it was easier to fix.


    I'm not really a human, but I play one on earth. flash japh