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

The email I am sending isn't displaying line breaks as expected. It was originally using BR tags but those displayed as text. So I thought, hey-- maybe if I convert the BR tags to \n it'll display correctly.

But again, \n comes back as text, not a line break. I am using Outlook Express and I know it's not sending in HTML (atleast I think not). How can I get line breaks to appear in all emails?

Thanks monks!

if ($email ne "") { $ourmessage =~ s/<br>/\\n/g; open (MAIL, "|$sendmail -t") or die "Cannot access mail"; print MAIL "To: $mail\n"; print MAIL "From: $adminmail\n"; print MAIL "Subject: Thank you\n\n"; print MAIL "$ourmessage\n"; close (MAIL); }

Replies are listed 'Best First'.
Re: email not line breaking properly
by graff (Chancellor) on Sep 27, 2004 at 05:16 UTC
    As sulfericacid was trying to say, don't use a double-backslash for "\n":
    $ourmessage =~ s/<br>/\n/g; # replace <br> with new-line
Re: email not line breaking properly
by sulfericacid (Deacon) on Sep 27, 2004 at 04:47 UTC
    If you remove the extra \ in \\n, it should work fine.

    You don't double slash the \n.

    I'm not 100% sure this'll work in all emails though, but it should work in most.

    Hope this helps.



    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

    sulfericacid