Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Net::smtp

Status
Not open for further replies.

greedyzebra

Technical User
Joined
Sep 5, 2001
Messages
140
Location
US
Hi,

I'm trying to find a method to be able to send mail using a script on Windows. I'm able to connect to my domain's smtp server, but it requires authorization. After a couple of hours searching (to no avail) to find an example of how to provide a username and password after connecting to the server, I am quite frustrated and hope someone can lend me a hand.

I have also tried to use Blat, but finding out how to do it with username and password is also proving to be impossible.

Thanks!
 
Perhaps since no one else's smtp servers apparently require authentication, I could just use someone else's? :)
 
I know of two ways, which are essentially equivalent, for doing plaintext smtp auth.
Code:
use Net::SMTP;
use MIME::Base64;

my $smtp = Net::SMTP->new($smtp_server);

# One way
my $auth_string = encode_base64("$user\0$user\0$pass");$smtp->command('AUTH', 'PLAIN', $auth_string);

# The other way
my $user_enc = encode_base64($user);
my $pass_enc = encode_base64($pass);
$smtp->command('AUTH', 'LOGIN');
$smtp->command($user_enc);
$smtp->command($pass_enc);

# Continue with sending message here
jaa
 
Excellent! Thanks very much!

I also found documentation for version 8 that that has an "auth" method in Net::SMTP. When I tried to use it I was missing a necessary module. Now I have that module and will try it as well. If anyone is interested, I'll be happy to post the results.

Thanks again,

Tom
 
Status
Not open for further replies.

Similar threads

  • Locked
  • Question Question
Replies
9
Views
620
Replies
1
Views
516

Part and Inventory Search

Sponsor

Back
Top