Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Getting Net::SMTP::SSL debug information

by sirsir (Initiate)
on Feb 04, 2009 at 13:48 UTC ( [id://741277]=perlquestion: print w/replies, xml ) Need Help??

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

I wrote this:
#!/usr/bin/perl -w use MIME::Base64; use Net::SMTP::SSL; my($User,$Password) = ('my_email@gmail.com', 'password'); $EncodedLogin = encode_base64("\00".$User."\0".$Password); my $smtp = Net::SMTP::SSL->new('smtp.gmail.com',Port=>465,Debug=>1,Hel +lo=>'mx.google.com'); $smtp->datasend("AUTH PLAIN " . $EncodedLogin); $smtp->dataend();
With Debug set to 1, here is the output I get:
Net::SMTP::SSL>>> Net::SMTP::SSL(1.01) Net::SMTP::SSL>>> IO::Socket::SSL(1.22) Net::SMTP::SSL>>> IO::Socket::INET(1.29) Net::SMTP::SSL>>> IO::Socket(1.29) Net::SMTP::SSL>>> IO::Handle(1.25) Net::SMTP::SSL>>> Exporter(5.58) Net::SMTP::SSL>>> Net::Cmd(2.26) Net::SMTP::SSL=GLOB(0x8413678)<<< 220 mx.google.com ESMTP 32sm13404522 +wfc.50 Net::SMTP::SSL=GLOB(0x8413678)>>> EHLO mx.google.com Net::SMTP::SSL=GLOB(0x8413678)<<< 250-mx.google.com at your service, [ +xxx.xx.xx.x] Net::SMTP::SSL=GLOB(0x8413678)<<< 250-SIZE 35651584 Net::SMTP::SSL=GLOB(0x8413678)<<< 250-8BITMIME Net::SMTP::SSL=GLOB(0x8413678)<<< 250-AUTH LOGIN PLAIN Net::SMTP::SSL=GLOB(0x8413678)<<< 250 ENHANCEDSTATUSCODES Net::SMTP::SSL=GLOB(0x8413678)>>> AUTH PLAIN base_64_encoded_string_of +_my_username_and_password== Net::SMTP::SSL=GLOB(0x8413678)>>> . Net::SMTP::SSL=GLOB(0x8413678)<<< 235 2.7.0 Accepted
How can I actually use this output to check response codes etc? Example:
if($smtp->response_code==235){ print("Accepted!\n"); } else{ printf("Auth failed\n"); }
I already tried the auth() method, and it always returns 0 no matter what username/password combo I use.

Replies are listed 'Best First'.
Re: Getting Net::SMTP::SSL debug information
by weismat (Friar) on Feb 04, 2009 at 14:04 UTC
    I use the auth method also via Net::SMTP::SSL against yahoo mail instead of google mail and it returns 1 if the authentication has worked.
    The odd part is that your SMTP status Code 235 indicates that the authentication has worked.
    I guess you need to step in the debugger to see where the problem starts...
    Update: Maybe you mixed the Net and the MIME module:
    my $smtp = Net::SMTP::SSL->new("", Debug=>1, Timeout=>20, Port=>465); $smtp->auth('', "") or die "Error message: $smtp->message";
    is what I do...
      How did you know the 'message()' method existed? It's not on the Net:SMTP documentation. I think I might just parse that and check if it sends Accepted or not.

Log In?
Username:
Password:

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

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

    No recent polls found