in reply to Error in MIME::Lite?

Hi,

Why are you calling build more than once?

The documentation does not show that usage

Replies are listed 'Best First'.
Re^2: Error in MIME::Lite?
by littlelion (Novice) on Jul 29, 2017 at 20:21 UTC
    I called build() twice for clarity. The test case fails with a single build() call.
    $msg->build(to => 'user1 <user@fqdn.org>', from => 'user2 <user2@fqdn. +org>', subject => 'a message subject'); % ./testmail.pp no data in this part at ./testmail.pp line 21.
    The problem is that the MIME::Lite->attach() creates a new part with no content unless the content-type is already set to multipart. This is not legal as far as MIME::Lite->send() is concerned.

    I tried setting content-type but that breaks the MIME formatting of the message (all the steps that attach() is doing unless it detects multipart).

      Hi

      I think build wants data also

        The poorly documented answer is that new() requires data. I was able to get it to work, but only when I either pass new() data (text, html or an attachment) or reproduce the logic in attach() to create a multi-part mime format. You can't create a new empty object and add data to it.