Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've got this bit of code:

$entity = MIME::Entity->build
(
Type => 'multipart/mixed',
From => 'blah@blah',
To => 'bloo@bloo',
Subject => "$subject",
)
or die "Error creating MIME entity: $!\n";

$entity->attach(
Type => 'text',
Encoding => 'base64',
Data=>@msg_body
);

$entity->smtpsend;

What happens is, the first line of @msg_body is sent as the email body, but nothing else. If I use:

Data=>join("",@msg_body)

then it all goes in there, but there seems to be no control of line returns. how can I separate each line of @msg_body with a line return?

Thanks.

Replies are listed 'Best First'.
Re: mime tools multiline body
by ikegami (Patriarch) on Sep 22, 2004 at 21:44 UTC
    'text' is not a MIME type, as far as I know. 'text/plain' is, and it's probably what you want. Maybe your mail reader treats the text as HTML by default, in which case, line returns would disappear. It might help to fix this.
Re: mime tools multiline body
by JediWizard (Deacon) on Sep 22, 2004 at 22:21 UTC

    Do the records in @msg_data end with a new line? If not you should probably try join("\n", @msg_body).

    Update: Doh! forgot a close tag... Thanks VSarkiss

    May the Force be with you
      I changed the type to text/plain and used join("\n", @msg_body) and this resulted in a literal "\n" being stuck between each element. It's not reading the line returns as line returns...any ideas?
        doh, I figured it out immediately. I was using '\n' instead of double quotes, so of course it wasn't reading them as line returns. Everything works great now, thanks for the help. As always I'm indebted to the monks...