I recently wrote a program that needs to send messages through SMTP every few minutes. Since I'm running this behind an Earthlink DSL modem, I can only connect on port 25 if I'm connecting to the Earthlink STMPAUTH server. (Damn them and their restrictions!).

Anyway, I wrote a script that sends the mail and it works perfectly. The problem is that if the message gets sent twice from the same script, I get an error and the mail doesn't go through. I figured it might have been the rest of my code, so I isolated the mailing sub and tried again. No dice. Why would this happen?

Here's my code:

#!/usr/bin/perl use Net::SMTP; use strict; use warnings; for(1..2) { my $smtp = Net::SMTP->new('smtpauth.earthlink.net', Hello => 'milkbone.org', Debug => 1) or die +"death"; $smtp->auth('batkins86@earthlink.net', '***************************'); $smtp->mail('monitor@milkbone.org'); $smtp->to('test@batkins.com'); $smtp->data(); $smtp->datasend("To: postmaster\n"); $smtp->datasend("\n"); $smtp->datasend("A simple test message\n"); $smtp->dataend(); $smtp->quit; }
Of course, the password is blanked out. The first time this goes through perfectly. But the second time, the tail end of the Debug output reads:
Net::SMTP=GLOB(0x81b38e0)<<< 250-puffin.mail.pas.earthlink.net Hello n +ode-423a0c29.lga.onnet.us.uu.net [66.58.12.41] Net::SMTP=GLOB(0x81b38e0)<<< 250-SIZE 10485760 Net::SMTP=GLOB(0x81b38e0)<<< 250-PIPELINING Net::SMTP=GLOB(0x81b38e0)<<< 250-AUTH PLAIN LOGIN CRAM-MD5 Net::SMTP=GLOB(0x81b38e0)<<< 250-STARTTLS Net::SMTP=GLOB(0x81b38e0)<<< 250 HELP Can't locate object method "_secflags" via package "Authen::SASL::Perl +::CRAM_MD5" at /usr/lib/perl5/site_perl/5.8.0/Authen/SASL/Perl.pm lin +e 32.
I'm stumped. Any ideas?
milkbone - perl/tk instant messaging - it's the only way to fly

You know anyone who'll debug two million lines of code for what I get this job?
- Dennis Nedry


In reply to Sending two messages thru an smtp server with authentication by batkins

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.