I don't know what the problem is. I looked through MIME::Lite, and the length of the strings that are encoded is set to 45. So I threw together the following program using a 35k jpeg to test. Maybe the problem is the file is too short?
#!/usr/bin/perl use MIME::Base64; use MIME::Lite; open FILE, "jpg/attachment-start.jpg"; while (read (FILE,$buf,45)) { $added .= encode_base64($buf); } open OUT1, ">blah1"; print OUT1 $added; close FILE; close OUT1; $msg = MIME::Lite->new(From => "me\@myhost.com", To => "blah\@blah.com", Type=> "image/jpg", Encoding =>"base64", Path => "jpg/attachment-start.jpg"); $message = $msg->as_string; open OUT2, ">blah2"; print OUT2 $message; close OUT2;
then I ran it, and deleted the header... yes, I'm sure I should have used $message = $msg->body_as_string or something like that, but I didn't.

then i did the following. ~$ diff blah1 blah2

There was no output. It works for a file size of 35k. Perhaps your file is too short?

Update: I slept on it and remembered that I left something out. If you set the "paranoid" flag in MIME::Lite, it will use it's own encoding scheme instead of calling MIME::Base64:encode_base64, as it does default, so this kind of behavior is really strange. The only difference in the way you are calling it and the way MIME::Lite calls it is that it calls it with a buffer size of (read (FH,$buf,45)) rather than (read (FH,$buf,1024)). So I stand by my earlier post... try setting the buffer size to 57*1.


In reply to RE: RE: RE: about MIME::Base64 by tenatious
in thread about MIME::Base64 by Delfer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.