perlmime-mail

perl mime::lite attach text file line feed error


my @test = ("Row1", "Row2", "Row3");
my $attch = join("<cr><lf><br>\\n", @test);

$message = MIME::Lite->new(
    From     => $mailFrom ,
    To       => $address,
    Subject  => $title,
    Type     => 'text/html',
    Encoding => '8bit',
    Data     => $data
);

$message->attach(
    Type     =>'TEXT',
    Data     => $attch
);

MIME::Lite->send('smtp', $host, Timeout => 20);
$message->send;

Good Day, i'm trying send a file in a email, but i cant write correct line feed, the code sends a email with a attached file, this attached file contains the next information:
"Row1<cr><lf><br>\nRow2<cr><lf><br>\nRow3"

How i can get:
Row1
Row2
Row3

In the attached file?


Solution

  • $message->attach(
       Type => 'TEXT',
       Data => join('', map { "$_\n" } @test),
    );