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.