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

Hello,

Is there a way to use NET::SMTP module for sending emails via SMTP server which requires authorization? Probably it is not a perl question?

--dda

Replies are listed 'Best First'.
Re: NET::SMTP and authorization
by RMGir (Prior) on Jan 22, 2003 at 17:12 UTC
    I'm not an SMTP expert by any means, but perldoc Net::SMTP says:
           auth ( USERNAME, PASSWORD )
               Attempt SASL authentication.  At this time only the
               PLAIN mechanism is supported.
    
               At some point in the future support for using
               Authen::SASL will be added
    
    I'm guessing that's probably what you're looking for?

    The code would look something like:

    use Net::SMTP; my $smtp=Net::SMTP->new('picky.server.com') or die "Can't connect to s +mtp server"; $smtp->auth('user','passwd') or die "Can't authenticate with smtp serv +er"; # rest of smtp session goes here, I guess
    You'll have to dig a bit through the SMTP sources, I'm not sure if auth really returns a false value on all failure paths, but I think so.
    --
    Mike
Re: NET::SMTP and authorization
by phydeauxarff (Priest) on Jan 22, 2003 at 22:23 UTC
    Have you checked out the documentation?
    http://search.cpan.org/author/GBARR/libnet-1.12/Net/SMTP.pm
    indicates that there is an Auth method that takes user,pass something like;
    $smtp = Net::SMTP->new('mailhost', 
          Hello => 'my.mail.domain' 
          Timeout => 30, 
          Debug   => 1, 
          Auth => 'username,password' 
          ); 

Re: NET::SMTP and authorization
by dda (Friar) on Jan 23, 2003 at 06:26 UTC
    Thank you guys, I had an older version of the module. Now the problem is gone.

    --dda