in reply to Re: Net::SMTP_auth install & usage
in thread Net::SMTP_auth install & usage

What would be the advantage of using Authen::SASL over Net::SMTP_auth? Hmmm, OK, I just read through the source code for SMTP_auth again and realized it's using the Authen::SASL to do the work anyway - is that right? I'm new to this you see :) Is it just a wrapper for SASL authentication?

My code is used on client machines, and I have no control over what the clients have installed or not, many of them with an ISP that won't install things just for me. (like SMTP_auth). That's why I asked earlier about transferring the code into my script, I can have it with me anywhere I (or my script) might go.

Replies are listed 'Best First'.
Re^3: Net::SMTP_auth install & usage
by Khen1950fx (Canon) on Jun 07, 2012 at 00:53 UTC
    I used Authen::SASL because because it has fewer dependencies. Net::SMTP_auth is built on top of Authen::SASL, but your clients are more likely to have Authen::SASL installed.
      Hi again, I am returning to my old post here. I tried the code you suggested, and I get an error, hopefully someone can help me with it. I have the debug on, so here is the webpage out put, my code follows:
      SMTP authNet::SMTP>>> Net::SMTP(2.29) Net::SMTP>>> Net::Cmd(2.26) Net: +:SMTP>>> Exporter(5.58) Net::SMTP>>> IO::Socket::INET(1.29) Net::SMTP +>>> IO::Socket(1.29) Net::SMTP>>> IO::Handle(1.25) Net::SMTP=GLOB(0x2 +a152d4)<<< 220 vinyl4.sentex.ca ESMTP Sendmail 8.14.5/8.14.5; Mon, 2 +Jul 2012 14:48:57 -0400 (EDT) Net::SMTP=GLOB(0x2a152d4)>>> EHLO local +host.localdomain Net::SMTP=GLOB(0x2a152d4)<<< 250-vinyl4.sentex.ca He +llo 50-56-96-131.static.cloud-ips.com [50.56.96.131], pleased to meet + you Net::SMTP=GLOB(0x2a152d4)<<< 250-ENHANCEDSTATUSCODES Net::SMTP=G +LOB(0x2a152d4)<<< 250-PIPELINING Net::SMTP=GLOB(0x2a152d4)<<< 250-8BI +TMIME Net::SMTP=GLOB(0x2a152d4)<<< 250-SIZE 30000000 Net::SMTP=GLOB(0 +x2a152d4)<<< 250-DSN Net::SMTP=GLOB(0x2a152d4)<<< 250-ETRN Net::SMTP= +GLOB(0x2a152d4)<<< 250-AUTH PLAIN LOGIN DIGEST-MD5 Net::SMTP=GLOB(0x2 +a152d4)<<< 250-STARTTLS Net::SMTP=GLOB(0x2a152d4)<<< 250-DELIVERBY Ne +t::SMTP=GLOB(0x2a152d4)<<< 250 HELP starting auth sending from [michael@thewhitings.ca] to [michael@thewhitings.ca]Net:: +SMTP=GLOB(0x2a152d4)>>> MAIL FROM: Net::SMTP=GLOB(0x2a152d4)<<< 250 2 +.1.0 ... Sender ok Net::SMTP=GLOB(0x2a152d4)>>> RCPT TO: Net::SMTP=GL +OB(0x2a152d4)<<< 550 5.7.1 ... Relaying denied. Proper authentication + required. Net::SMTP=GLOB(0x2a152d4)>>> DATA Net::SMTP=GLOB(0x2a152d4 +)<<< 503 5.0.0 Need RCPT (recipient) Text:To: michael@thewhitings.ca Software error: Can't call method "datasend" on an undefined value at C:\inetpub\wwwro +ot\dev\abc.exe line 1354.
      You can see the Relaying denied. Proper authentication required. error in there. It seems to be getting past the 'die' statement when running the &auth subroutine, and then choking when it tries to send data. Here is my code currently:
      sub main { use Net::SMTP; $SMTPServer = 'localhost' unless (defined $SMTPServer); BEGIN { $| = 1; require MIME::Base64; require Authen::SASL; } my $host = $SMTPServer; my $user = $mainlogin; my $pass = $mainpwd; my $NetSMTP = Net::SMTP->new( Host => $host, Time => 30, Debug => 1, ); my $sasl; my $mechanisms = ['AUTH', 500]; print "starting auth<br>"; die "Couldn't auth sasl login: $!" unless \&auth; $NetSMTP->mail($emailFrom); $NetSMTP->to($LibDef{$LibName}[1]); $NetSMTP->data(); $NetSMTP->datasend('test text'); close (MAIL); print "<br><br><b>$REQUESTPAGE_TEXT_THANKYOU</b>"; } sub auth { my $sasl = Authen::SASL->new( mechanism => $mechanisms, debug => 1, callback => { user => $user, pass => $pass, authname => $user, ); }