http://www.perlmonks.org?node_id=1098581


in reply to Re: Sending An Attachment Using Net::SMTP
in thread Sending An Attachment Using Net::SMTP

To make encoding to base64 better, use a chunk/buffer that is a multiple of 57 bytes. This will enable sending of large files.

In the code that alejandro posted, the line:

while (read(DAT, my $picture, 4096)) {

could become:

while (read(DAT, my $picture, 72*57)) {

To read a bit more about this, see the examples section in http://perldoc.perl.org/MIME/Base64.html