Hi
i wrote a simple script to send email using MIME:Lite on Linux machine.
I am trying to write the email body from a flat file, but the new line characters are not appearing in the email body.
Sample code:
my $mime_msg = MIME::Lite->new(
From => $from_user,
To => $to_users,
Bcc => $bcc_users,
Cc => $cc_users,
Subject => $subject,
Type => "multipart/related") or die "Error creating MIME bod
+y: $!\n";
my $body='/tmp/file.txt'
$mime_msg->attach(Type => 'text/html', Path => $body, Filename => $bod
+y ) or die "Error attaching html: $!\n";
$smtp->data();
$smtp->datasend($message_body);
$smtp->dataend();
#close connection
$smtp->quit();
=== file1.txt ==
Line one
line two
line three
I am able to send an email but the body of the email is not as expected. the new lines are stripped out.
===== Mail body ===
Line one line two line three
I am wondering hot to get the mail body as is in the file1.txt ie line breaks are missing. I am not sure why perl is not considering the new line chars as line breaks.
Appreciate you help.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.