Notice that MIME::Lite::attach() created 2 parts, one (part0) master with no data and part1 with the text data, but send() barfs on this. Is this a bug in the module or am I doing something wrong?

Not a bug. If you create a message, there should be data in it, even if it is no data:

qwurx [shmem] ~> perl -MMIME::Lite -le '$m=MIME::Lite->new(Data=>"foo" +);$m->print' Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain MIME-Version: 1.0 X-Mailer: MIME::Lite 3.030 (F2.85; T2.09; A2.13; B3.14; Q3.13) Date: Sun, 30 Jul 2017 02:30:09 +0200 foo

Also:

qwurx [shmem] ~> perl -MMIME::Lite -le '$m=MIME::Lite->new;$m->build(f +rom => "me", to =>"you", Data => "kisses"); $m->print' Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain MIME-Version: 1.0 X-Mailer: MIME::Lite 3.030 (F2.85; T2.09; A2.13; B3.14; Q3.13) Date: Sun, 30 Jul 2017 02:32:39 +0200 From: me To: you kisses

These are just plain messages. You can also build a message with no data using Data => "" in the constructor or build(). MIME::Lite builds a multipart message only if there are, well, multiple parts.

use MIME::Lite; $m = MIME::Lite->new; $m->build( from => 'me', to => 'you', Data => '', subject => 'Foo Bar', ); $m->attach( Type => 'text/plain', Data => 'this is an attachment' ); $m->print; __END__ Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_150137533476690" MIME-Version: 1.0 Date: Sun, 30 Jul 2017 02:42:14 +0200 From: me To: you Subject: Foo Bar X-Mailer: MIME::Lite 3.030 (F2.85; T2.09; A2.13; B3.14; Q3.13) This is a multi-part message in MIME format. --_----------=_150137533476690 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain --_----------=_150137533476690 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain this is an attachment --_----------=_150137533476690--

What you have gotten wrong is this part in your code

$msg->attach( Type => 'text/plain', Data => 'This is the body text of the email', );

It isn't the body text of the mail. It is an attachment. The body part is the first part of the multipart message, and you must provide data for it (even an empty string works) either in the constructor, or the build or the data method invoked upon the MIME::Lite object.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

In reply to Re: Error in MIME::Lite? by shmem
in thread Error in MIME::Lite? by littlelion

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.