in reply to Emailing attachments.

Hi, I just tested mailing an excel sheet thru Gmail, with MIME::Lite and it worked fine. The only real difference, from yours, is I set the Encoding for the Excel attachment. I also used Net::SMTP::SSL instead of Net::SMTP::TLS, but I don't think the problem lies there. If you want to see a copy of my script, let me know.
$msg->attach( Type => 'application/vnd.ms-excel', Path => './zz.xls', Filename => 'college_orders.xls', Encoding => 'base64' );

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Emailing attachments.
by mailmeakhila (Sexton) on Jul 06, 2012 at 18:07 UTC
    Hi It worked for very small excel sheets but failed for sizes 0.025 and above. Let me know your view. Also if you want to see code. update:0.025MB Thank you Akhila.
      My sample xls file was .8MB or over 800K. If you are failing with a size limit, I doubt it is Perl's fault. FWIW, I had a similar problem awhile back, where I couldn't make any attachments over 3 MB. It turned out it was some limitation of the wireless repeater I was using. Can you test with a direct connection to an ethernet cable?

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
        Ill test it out and let you know. If that is the case it can also be the limitation of the file size my mail server will allow.
Re^2: Emailing attachments.
by mailmeakhila (Sexton) on Jul 17, 2012 at 17:19 UTC
    Hi I am not having any luck with emailing attachments. Can you send me a copy of your script. Thank you Akhila
      Here you go:
      #!/usr/bin/perl use warnings; use strict; use Net::SMTP::SSL; + use MIME::Lite; # Implements the same API as Net::SMTP, but uses IO::Socket::SSL for i +ts # network operations. Due to the nature of "Net::SMTP"'s "new" method, + it # is not overridden to make use of a default port for the SMTPS servic +e. # Perhaps future versions will be smart like that. Port 465 is usually + # what you want, and it's not a pain to specify that. # GMAIL's virus scanners have trouble with .zip and .exe attachments?? # and the smtp server rejects mails with those attachments #$server = 'your-smtp-server'; my $server = 'smtp.gmail.com'; my $to = 'who@freak.com'; my $from_name = 'me'; my $from_email = 'me@gmail.com'; my $subject = 'smtp-ssl-auth attach test'; my $user = 'me@gmail.com'; my $pass = 'my_password'; my $msg = MIME::Lite->new( From => $from_email, To => $to, Subject =>'test message', Type =>'TEXT', Data =>'This is a test, i repeat only a test', ); #$msg->attach(Type =>'application/octet-stream', #Encoding =>'base64', #Path =>'./zenbw_l.jpg', #); $msg->attach( Type => 'application/vnd.ms-excel', Path => './zz.xls', Filename => 'college_orders.xls', Encoding => 'base64' ); my $smtps = Net::SMTP::SSL->new($server, Port => 465, DEBUG => 1, ) or warn "$!\n"; # I hust lucked out and this worked defined ($smtps->auth($user, $pass)) or die "Can't authenticate: $!\n"; $smtps->mail($from_email); $smtps->to($to); $smtps->data(); $smtps->datasend( $msg->as_string() ); $smtps->dataend(); $smtps->quit(); print "done\n"; #You can alternatively just put everything in the argument to $smtp->d +ata(), #and forget about datasend() and dataend();

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
        Hi Thank you very much. The problem was with Net::SMTP::TLS by changing it to Net::SMTP::SSL solved the problem. Thanks again. Akhila