develooper Front page | perl.beginners | Postings from April 2012

Re: Sending files efficiently with Net::SMTP

Thread Previous | Thread Next
From:
Jenda Krynicky
Date:
April 2, 2012 00:39
Subject:
Re: Sending files efficiently with Net::SMTP
Message ID:
4F7957A9.22650.115EA510@Jenda.Krynicky.cz
From:           	mailing lists <listas.correo@yahoo.es>
> I have a perl (Ver. 5.10.0) program running over an old machine which send messages with this code:
>
>
>     my $smtp = Net::SMTP->new($dstMailServer, Timeout=>10, Debug=>0,);
>     unless(defined($smtp)){
>         syslog LOG_INFO, "id:%s error: unable to connect with %s", $myid, $dstMailServer;
>         exit $EX_TEMPFAIL;
>     }  
>     $smtp->mail($sender);
>     $smtp->to($recipient);
>     $smtp->data();
>     my $line;
>     open INPUTFILE, "<", $outfile or die "couldn't open $outfile";
>     while(defined($line=<INPUTFILE>)){
>         $smtp->datasend($line);
>     }
>     close INPUTFILE;
>     $smtp->dataend();
>     $smtp->quit;
>
>
> since the machine belongs to a third party I have no possibility to
> install perl modules (no internet connection, compilers, etc) like
> Slurp. So sending files in the MB range is very slow. Anyone know how
> to optimize (if possible) this code?


Read (and send) the files by blocks (8kb sounds reasonable) instead
of lines.

See
	perldoc -f read

not sure it'll help much though.

Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
	-- Terry Pratchett in Sourcery


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About