Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Net::SMTP - Authentication Problem

by zentara (Archbishop)
on Aug 29, 2006 at 12:06 UTC ( #570138=note: print w/replies, xml ) Need Help??

in reply to Net::SMTP - Authentication Problem

Maybe try the Net::SMTP_auth module?
#!/usr/bin/perl use warnings; use strict; use Net::SMTP_auth; my $smtp = Net::SMTP_auth->new(''); $smtp->auth('LOGIN', 'z', 'ztest'); $smtp->mail(''); $smtp->to(''); $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

Replies are listed 'Best First'.
Re^2: Net::SMTP - Authentication Problem
by Anonymous Monk on Feb 12, 2008 at 01:08 UTC
    use Net::SMTP::TLS

    It's the version made to properly support authentication. For whatever reason, Net::SMTP seems not to.
Re^2: Net::SMTP - Authentication Problem
by vi_srikanth (Acolyte) on Aug 29, 2006 at 13:38 UTC

    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.


      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


        In the system in which SMTP is not working thru perl, I tried with PHP. It works precisely with PHP. Here is the PHP code:

        <?php require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to + use SMTP $mail->Host = ""; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "srikanth"; // SMTP username $mail->Password = "mypass"; // SMTP password $mail->From = ""; $mail->AddAddress(""); // name is op +tional $mail->Subject = "Here is the subject"; $mail->Body = "This is the HTML message body"; $mail->AltBody = "This is the body in plain text for non-HTML mail cli +ents"; if(!$mail->Send()) { echo "Message could not be sent."; } else { echo "Message has been sent"; } ?>

        And, here is the debug=>1 output by Perl:

        Net::SMTP_auth>>> Net::SMTP_auth(0.08) Net::SMTP_auth>>> Net::SMTP(2.29) Net::SMTP_auth>>> Net::Cmd(2.26) Net::SMTP_auth>>> Exporter(5.58) Net::SMTP_auth>>> IO::Socket::INET(1.31) Net::SMTP_auth>>> IO::Socket(1.30) Net::SMTP_auth>>> IO::Handle(1.27) Net::SMTP_auth=GLOB(0x81faaa8)<<< 220 ESMTP Net::SMTP_auth=GLOB(0x81faaa8)>>> EHLO localhost.localdomain Net::SMTP_auth=GLOB(0x81faaa8)<<< Net::SMTP_auth=GLOB(0x81faaa8)<<< 250-PIPELINING Net::SMTP_auth=GLOB(0x81faaa8)<<< 250-SIZE 20480000 Net::SMTP_auth=GLOB(0x81faaa8)<<< 250-VRFY Net::SMTP_auth=GLOB(0x81faaa8)<<< 250-ETRN Net::SMTP_auth=GLOB(0x81faaa8)<<< 250-AUTH PLAIN LOGIN Net::SMTP_auth=GLOB(0x81faaa8)<<< 250 8BITMIME Unknown callback: 'authname'. (user|auth|language|pas

        Also I have tried PLAIN & CRAM-MD5 apart from LOGIN

        Any suggestion?


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://570138]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2018-07-15 19:55 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (326 votes). Check out past polls.