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

Hi, I've taken the basic perl script for sending an email.
$smtp = Net::SMTP->new($mail) or die "Couldn't connect to server";
It has authentication around it - or it has on outlook anyway. Is there a way to send my authentication to the server to enable me to send emails? I can't see it in any methods to add my user id and passwords.

Replies are listed 'Best First'.
Re: SMTP - Needs authentication.
by tirwhan (Abbot) on Nov 09, 2005 at 19:04 UTC

    Take a look at

    perldoc Net::SMTP

    , particularly the auth() method. You need to have the MIME::Base64 and Authen::SASL modules installed for that to work though.

Re: SMTP - Needs authentication.
by zentara (Cardinal) on Nov 09, 2005 at 19:34 UTC
    #!/usr/bin/perl use warnings; use strict; use Net::SMTP_auth; my $smtp = Net::SMTP_auth->new('zentara.zentara.net'); $smtp->auth('LOGIN', 'z', 'ztestpass'); $smtp->mail('z@zentara.zentara.net'); $smtp->to('zentara@zentara.zentara.net'); $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. flash japh