http://qs1969.pair.com?node_id=62691


in reply to SMTP and Authentication

How does your ISP require you to authenticate -- is it SMTP AUTH or POP-before-SMTP or something even more exotic? If it's POP-before-SMTP, use Net::POP3 to log into the POP server once per session, before submitting any outgoing mail (you shouldn't need to actually download any messages).

If it's SMTP AUTH it looks like you might be out of luck, unless you feel like adding this functionality yourself (which actually doesn't look that difficult).

Replies are listed 'Best First'.
Re: Re: SMTP and Authentication
by mdog (Pilgrim) on Mar 07, 2001 at 22:03 UTC
    If they only used POP-before-SMTP! Alas, it is SMTP AUTH. If anyone has battled with this before and already solved this problem, could they please post any relevant code? Otherwise, I'll take a look at tackling it myself. Thanks!
Re: Re: SMTP and Authentication WITH USING Net::SMTP
by Anonymous Monk on Mar 27, 2002 at 22:29 UTC
    MY ANSWER IS BELOW. THIS WORKS.
    ===============================


    use Net::SMTP;
    use MIME::Base64;

    $user = encode_base64($username);
    $pass = encode_base64($password);
    chomp($user);
    chomp($pass);

    $smtp->command('AUTH LOGIN');
    $smtp->command("$user");
    $smtp->command("$pass");

      I was struggling with the same thing and have tried your code. I am getting strange results: sometimes I am getting encouraging codes back such as 250 ("ok") and 354 ("go ahead") but often I get 502 ("unimplemented (#5.5.1)"). There seems to be no pattern in a series of 10 emails sent out through the same connection - codes seem random and some of the email is delivered, while most is not. Any ideas? thanks. (See below for the Debug output result after sending 2 messages -both undelivered)
      Net::SMTP: Net::SMTP(2.13) Net::SMTP: Net::Cmd(2.12) Net::SMTP: Export +er(5.562) Net::SMTP: IO::Socket::INET(1.25) Net::SMTP: IO::Socket(1.2 +6) Net::SMTP: IO::Handle(1.21) Net::SMTP=GLOB(0x104834)<<< 220 www.my +isp.com ESMTP Net::SMTP=GLOB(0x104834)>>> EHLO www2.myisp.net Net::SMTP=GLOB(0x104834)<<< 250-www.myisp.com Net::SMTP=GLOB(0x104834)<<< 250-PIPELINING Net::SMTP=GLOB(0x104834)<<< 250 8BITMIME Net::SMTP=GLOB(0x104834)>>> AUTH LOGIN Net::SMTP=GLOB(0x104834)>>> ZGVsZWdhXzE= Net::SMTP=GLOB(0x104834)>>> am93b2JvMTI= Net::SMTP=GLOB(0x104834)>>> MAIL FROM: Net::SMTP=GLOB(0x104834)<<< 502 unimplemented (#5.5.1) Net::SMTP=GLOB(0x104834)>>> RCPT TO: Net::SMTP=GLOB(0x104834)<<< 354 go ahead Net::SMTP=GLOB(0x104834)>>> DATA Net::SMTP=GLOB(0x104834)<<< 250 ok 1019918963 qp 4227 Net::SMTP=GLOB(0x104834)>>> To: myself@hotmail.com Net::SMTP=GLOB(0x104834)>>> From: theprogram@mydomain.com Net::SMTP=GLOB(0x104834)>>> Subject: first test Net::SMTP=GLOB(0x104834)>>> Net::SMTP=GLOB(0x104834)>>> testing... Net::SMTP=GLOB(0x104834)>>> . Net::SMTP=GLOB(0x104834)<<< 502 unimplemented (#5.5.1) Net::SMTP=GLOB(0x104834)>>> AUTH LOGIN Net::SMTP=GLOB(0x104834)>>> ZGVsZMdhXzE= Net::SMTP=GLOB(0x104834)>>> am93b3JvMTI= Net::SMTP=GLOB(0x104834)>>> MAIL FROM: Net::SMTP=GLOB(0x104834)<<< 502 unimplemented (#5.5.1) Net::SMTP=GLOB(0x104834)>>> RCPT TO: Net::SMTP=GLOB(0x104834)<<< 502 unimplemented (#5.5.1) Net::SMTP=GLOB(0x104834)>>> DATA Net::SMTP=GLOB(0x104834)<<< 502 unimplemented (#5.5.1) Net::SMTP=GLOB(0x104834)>>> To: myself@hotmail.com Net::SMTP=GLOB(0x104834)>>> From: theprogram@mydomain.com Net::SMTP=GLOB(0x104834)>>> Subject: second test Net::SMTP=GLOB(0x104834)>>> Net::SMTP=GLOB(0x104834)>>> Hi, this is another test Net::SMTP=GLOB(0x104834)>>> . Net::SMTP=GLOB(0x104834)<<< 250 ok Net::SMTP=GLOB(0x104834)>>> QUIT Net::SMTP=GLOB(0x104834)<<< 250 ok
Re: Re: SMTP and Authentication
by krkeegan (Novice) on Nov 02, 2001 at 06:44 UTC
    I think I have the solution for you. I found out that SMTP AUTH isn't as secure as people would like you to believe. Check out my page to see my code and you can also check to see if it works with your server before downloading.

    http://www.krkeegan.com/smtp_auth

    Kevin Robert Keegan