Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
XP is just a number
 
PerlMonks  

Net::SMTP - Authentication Problem

by vi_srikanth (Acolyte)
on Aug 29, 2006 at 10:06 UTC ( #570121=perlquestion: print w/ replies, xml ) Need Help??
vi_srikanth has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I am using the following code to send a test mail:

use Net::SMTP; $smtp = Net::SMTP->new('pop.myserver.com); $smtp->auth('myusername', 'mypassword'); $smtp->mail('from@emailaddress.com'); $smtp->to('to@emailaddress.com'); $smtp->data(); $smtp->datasend("Subject: test smtp\n"); $smtp->datasend("test\n"); $smtp->dataend(); $smtp->quit;

It works precisely in one system, whereas it is showing up the following error in another system:

Unknown callback: 'authname'. (user|auth|language|pass)

Any idea?

Thanks
Srikanth

Comment on Net::SMTP - Authentication Problem
Download Code
Re: Net::SMTP - Authentication Problem
by Khen1950fx (Canon) on Aug 29, 2006 at 11:30 UTC
    If it works on one system, but you get an error message on another, then it's probably a protocol problem. You might try using Authen::SASL. It's designed so that all protocols can share the connection.

    Authen::SASL

    For an interesting article on SMTP AUTH, see:

    SMTP AUTH in sendmail 8.10-8.13

Re: Net::SMTP - Authentication Problem
by dtr (Scribe) on Aug 29, 2006 at 11:38 UTC

    Net::SMTP uses Authen::SASL internally to do the authentication. You should check to make sure that this is installed on both machines. Authen::SASL comes in several flavours, including Authen::SASL::Perl (pure perl) and Authen::SASL::Cyrus (using XS to link to the cyrus libraries). Check that you have the same one installed on both systems.

    You're not doing any error checking in the above code either. You should make sure that each of the auth(), mail(), to(), and data() functions return a true value, and if they do not, use the $smtp->message() method to get the error message back.

    You can use Ethereal to look at what is actually being sent to your mail server too - this is sometimes useful

      Please note that both the systems are having same versions of Authen::SASL::Perl.

      I tried $smtp->message. For "new" I get the following output:

      pop.myserver.com PIPELINING SIZE 20480000 VRFY ETRN AUTH PLAIN LOGIN 8BITMIME

      For "auth" I am not getting any return values, instead:

      Unknown callback: 'authname'. (user|auth|language|pass)

      Now, I am trying with Ethereal to troubleshoot this.

      By the way if you have any more suggestions please let me know.

      Thanks

Re: Net::SMTP - Authentication Problem
by zentara (Archbishop) on Aug 29, 2006 at 12:06 UTC
    Maybe try the Net::SMTP_auth module?
    #!/usr/bin/perl use warnings; use strict; use Net::SMTP_auth; my $smtp = Net::SMTP_auth->new('zentara.zentara.net'); $smtp->auth('LOGIN', 'z', 'ztest'); $smtp->mail('z@zentara.zentara.net'); $smtp->to('zentara@zentara.zentara.net'); $smtp->data(); $smtp->datasend("To: postmaster\n"); $smtp->datasend("\n"); $smtp->datasend("A simple test message\n"); $smtp->dataend(); $smtp->quit;

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum

      I tried SMTP_auth as you have suggested. It also fails. I check this in the system in which Net::SMTP works, it works in that system precisely.

      Kindly let me know if you have any suggestions.

      Thanks

        One of the things I can think of, is the auth_type is wrong. I showed a 'LOGIN' auth_type, but there is a choice of PLAIN, LOGIN, or CRAM-MD5.

        Also try turning on Debug and see if you can catch the error.

        my $smtp = Net::SMTP_auth->new($Servername, Port=>$Port, Debug => 1 );

        You also might want to capture the transaction with ethereal or tcpick

        Did you ever consider the other system dosn't support SMTP auth? Or the port it runs it on is different from the working system? Many systems run auth on port 587, but they can put it wherever they want.


        I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      use Net::SMTP::TLS http://search.cpan.org/~awestholm/Net-SMTP-TLS-0.12/lib/Net/SMTP/TLS.pm

      It's the version made to properly support authentication. For whatever reason, Net::SMTP seems not to.
Re: Net::SMTP - Authentication Problem
by Anonymous Monk on Aug 29, 2006 at 14:56 UTC
    Please don't use color for your code.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://570121]
Approved by prasadbabu
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2014-04-20 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (487 votes), past polls