I've been tearing my hair out over this one. All I'm trying to do is to get perl to do what I can already do by telnetting to my mail server over port 25 and entering in all the details manually.

When I telnet in, I use auth login and then enter the username and password in Base64. This works fine.

Now I want to get perl to do the same, so after much consultation of CPAN and throwing away Mail::Mailer as useless, I wrote the following (sanitised, of course):

#!/usr/bin/perl # # use strict; use Net::SMTP; my $DEBUG = 1; my $smtp; $smtp = Net::SMTP->new('mymailserver.net', Hello => "myotherserver.net +", Debug => 1,); die "Couldn't connect to server" unless $smtp; print "Server connection opened\n"; $smtp->auth('myuser', 'test123'); ...

When I run this, I get the following:

Net::SMTP>>> Net::SMTP(2.31) Net::SMTP>>> Net::Cmd(2.29) 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(0xa6fd440)<<< 220 mymailserver.net ESMTP Exim 4.60 Mon, + 20 Jul 2009 15:08:52 +0100 Net::SMTP=GLOB(0xa6fd440)>>> EHLO myotherserver.net Net::SMTP=GLOB(0xa6fd440)<<< 250-mymailserver.net Hello myotherserver. +net [10.1.2.70] Net::SMTP=GLOB(0xa6fd440)<<< 250-SIZE 20971520 Net::SMTP=GLOB(0xa6fd440)<<< 250-PIPELINING Net::SMTP=GLOB(0xa6fd440)<<< 250-AUTH PLAIN LOGIN Net::SMTP=GLOB(0xa6fd440)<<< 250-STARTTLS Net::SMTP=GLOB(0xa6fd440)<<< 250 HELP Server connection opened Net::SMTP=GLOB(0xa6fd440)>>> AUTH PLAIN bXl1c2VybXl1c2VydGVzdDEyMw== Net::SMTP=GLOB(0xa6fd440)<<< 535 Incorrect authentication data ...

The problem seems to be twofold:

  1. Instead of using AUTH LOGIN, it's using AUTH PLAIN
  2. The Base64 string contains the username twice, then the password, which is wrong.

Is this a bug in Net::SMTP, or a problem with my mail server, or something else?


In reply to Net::SMTP auth login fails - passes in username twice! by m0thr4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.