Dear Monks,

I am facing issues while sending mail using Mail::Mailer module.I need a way to send body containing multiple lines using the Mail::Mailer module. Hope you people might have faced this issue at any of your tasks which used Mail::Mailer. The requirement is, I have to read the contents from a file and need to send the file contents as the body message to the mail.

The problem here is, when i send the mail, the body contains only the first line of the file. The remaining contents are not available in the body part. But, if i replace the newline characters from the file contents with the string  '<br>', the remaining contents are coming properly.

I need your valuable suggestions for,


Here is my code,
my $mailer = new Mail::Mailer 'smtp', Server => 'localhost' or die "Co +uldn't create a mail object!\n"; my $mail_headers = { 'Content-Type' => 'text/plain', #I tried with 'text/html' for html + body. But that one was also failed :( To => [ $to ], From => 'root@mydomain.com', Subject => $subject, }; $mailer->open( $mail_headers ); $mailer->print($mailContents); #$mailContents - Contains the file cont +ents with new lines. $mailer->close();
Thanks for your valuable time.

Regards,
S.Venni Rajan.
"A Flair For Excellence."
                 BK Systems.

In reply to How to send mail containing multiple lines using Mail::Mailer? by vennirajan

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.