Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

MIME::lite and Net::SMTP::TLS - split attachment

by Anonymous Monk
on Jul 04, 2011 at 09:26 UTC ( #912618=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

below is a script that suppose to send an email with a single attachment (doc file) the script send the mail but split the attachment to multiple parts (14) )i guess its because the Type=>), any idea on how to resolve this issue ?

use strict; use warnings; use FindBin; use Net::SMTP::TLS; use MIME::Lite; use lib ("$FindBin::Bin/CPAN"); my $msg = MIME::Lite->new( From => 'mail', To => 'mail', Subject => 'Perl Test', Type =>'multipart/signed', ); $msg->attach( Type => 'application/msword', Path => 'some path', Filename => 'FORM50.doc', Disposition => 'attachment', ); my $mailer = new Net::SMTP::TLS( 'smtp.gmail.com', Port => 587, User => 'user', Password=> 'password'); $mailer->mail('mail'); $mailer->to('mail'); $mailer->data; $mailer->datasend($msg->as_string); $mailer->dataend; $mailer->quit;

Comment on MIME::lite and Net::SMTP::TLS - split attachment
Download Code
Re: MIME::lite and Net::SMTP::TLS - split attachment
by ig (Vicar) on Jul 04, 2011 at 16:56 UTC

    Why do you think the attachment is split into 14 parts?

    You could write $msg->as_string to a log file to see if the attachment is split into 14 parts at that point or some time later in processing. On Debian Linux, MIME::Lite does not split an attachment into multiple parts given arguments similar to what you are using:

    use strict; use warnings; use MIME::Lite; my $msg = MIME::Lite->new( From => 'mail', To => 'mail', Subject => 'Perl Test', Type => 'multipart/signed', ); $msg->attach( Type => 'application/msword', Path => 'test.doc', Filename => 'FORM50.doc', Disposition => 'attachment', ); print $msg->as_string . "\n";

    Maybe the attachment is being split at the receiving end of the communication? How are you receiving the email and saving the attachment?

Re: MIME::lite and Net::SMTP::TLS - split attachment
by jethro (Monsignor) on Jul 05, 2011 at 08:47 UTC
    What is the size of FORM50.doc? Did you try your script with smaller file sizes?
Re: MIME::lite and Net::SMTP::TLS - split attachment
by aturtle (Novice) on Oct 01, 2011 at 17:59 UTC
    Go to Tls.pm line 369 ($len -= $w;) add a new line 370: $offset += $w; I think this is a known bug in Net::SMTP::TLS (Tls.pm) On my Gentoo box the file is located at: /usr/lib/perl5/vendor_perl/5.14.1/Net/SMTP
      aturtle: I had the same problem. Your tip with the bug is perfekt. Thankyou!
      You are a genius. Since three days, I am trying to send a mail to gmail with and without attachments. Your code worked fine and the fix and its awesome. Thanks a lot.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://912618]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2014-10-25 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (140 votes), past polls