Hi Monks, I have a question on a limitation I'm finding using Net::SMTP with string sizes over (around) 4000 characters. I have a small timesheet system that our company uses. It's written for the web and the way it works is all the data is kept in a sql server and then at the end of the day a automatic status report is generated and e-mailed to the user. These status reports can get pretty large because the boss likes to know details on everything we're doing, that's why I wrote it. It's been running for about a year and a half now with no problem then all of a sudden a status report failed to be sent the other day. First of all we're using Microsoft's SMTP and I'm not sure if this is a Net::SMTP problem or Microsoft's SMTP, so please forgive me now if this is not Perl-related, but I'm really not sure and that's why I'm posting. I noticed that the reason this e-mail didn't get sent is because the $body of the email was so large that either Net::SMTP or Microsoft's SMTP service could not handle it. Is there a limit. It's certainly not anything special code-wise.

# Set the smtp variables. $server = "mysmtpserver"; $sender = "$userName\@mydomain.com"; $addr = "$userName\@mydomain.com"; $subject = $cgi->param('subject'); $body = $cgi->param('EmailBody'); $body =~ s/\r\n/\n/g; my $smtp = Net::SMTP->new($server); $smtp->mail($sender); $smtp->to($addr); $smtp->data(); $smtp->datasend("From: $sender\n"); $smtp->datasend("To: $addr\n"); $smtp->datasend("Subject: Status Report $subject_date\n"); $smtp->datasend("$body\n");
That's not the full code, but the jist of the Net::SMTP code. The way I know that it fails over around 4000 chars is I have some code to split the $body into 3000 character strings with newlines at the end and that works fine. Now pretend that the $body var is at least 4500 characters. The mail will get stuck in the BADMAIL with this error...

This is a MIME-formatted message. Portions of this message may be unreadable without a MIME-capable mail program.

Again, I'm not sure if this is even a Perl problem, so excuse my ignorance if it's not Perl-related at all.

In reply to Net::SMTP - Length limitation. by the_0ne

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.