Also, if I understand the RFC for email, you need two line feeds between the header and the body of the email message. So it looks like this instead:

$smtp->datasend( "Subject: FTP Access \n" ); $smtp->datasend( "\n\n" ); #Send the body
I tend to use MIME::Lite to construct the message, then its ->body_as_string() and ->header_as_string() methods, to feed into the $smtp->datasend() methods.

Also, Net::SMTP has a debug flag you can set in its constructor, which will give you very verbose feedback, every step of the way. Did you check the return value of your constructor? If the smtp server can not be reached, the constructor should fail. After reviewing perdoc for this module to make sure I got this right, try something like this:

my $smtp = Net::SMTP->new($smtp_server, Hello => $my_mail_servers_id, Debug => 1 ) or return 0;
When you've got this worked out, turn debug off, by setting it to 0, in the constructor.

-- Hugh

if( $lal && $lol ) { $life++; }

In reply to Re: Net::SMTP and Arrays by hesco
in thread Net::SMTP and Arrays by raj8

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.