On 10/03/2016 06:51 AM, Mike Martin wrote:
Hi
I have the below script (extracted pertinent bits).
The connection to the mail server times out if there is more than
about 10 lines of text (sometimes less)
i can't debug your email problem but there are several things you can do
to help yourself.
$text ="
use here documents for long multiline strings like that. it is hard to
find a close quote after so many lines.
use Net::SMTP::SSL;
use MIME::Base64;
use Email::Sender::Simple qw(sendmail);
use Email::MIME;
use IO::All;
use Email::Sender::Transport::SMTPS;
i don't think you need to load all those modules directly. some should
be loaded by others that you use if they are needed.
i don't see use strict or use warnings. those are important to enable as
they will help you find bugs more quickly.
sub sendemail {
my ($fname,$email,$rowid,$momstatus,$labstatus,$subject,$body)=@_;
print
$fname,"\t",$email,"\t",$subject,"\t",$rowid,"\t",$status1,"\t",$status2,"\n";
where are $status1 and $status2 declared or assigned? if this is part of
a script, try to reduce the script to the minimum that also has the bug
and post that.
my $message;
$message= "
Hi $fname
$body";
print $rowid,"\n",'lp_status'."\t",$labstatus,"\t".'momstatus'."\n";
note that momstatus is a string and not a variable there. also it is
much cleaner to put all that (and you do it several places) into one string:
print "$rowid\n$lp_status\t$labstatus\t$momstatus\n";
that is much easier to read and edit.
my $footer;
if (<check1>){
that is reading from the filehandle check1. handle names should be upper
case and even better as a variable using an anonymous glob (what lies
inside the handle).
$footer="\n
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, <url
hereuuuuuuuuuuuuuuuuuuuuuuuuuu>
";
}
if (check2){
that is not even a read of a handle as it is missing the <>. it is a
call to a (possibly missing) sub. strict and warnings would tell you that.
clean up the code a bit, use better formatting, use strict and warnings
and see what shows up. you may just fix this on your own. if you need
more help after that, try to focus on the email sending part and remove
all the mime stuff. if you can send any length plain email or not, that
will be a useful clue.
thanx,
uri
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/