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

Hi, I'm writing code which sends e-mail using Mail::Sendmail and am having a small problem. When I send the message with newline characters (\n in this case), they're not interpreted as newlines in the e-mail client. I'm using Evolution e-mail, but am having the same problem in Outlook on a Windows box. What's the trick here? Thanks

Replies are listed 'Best First'.
Re: e-mail with newlines
by castaway (Parson) on Jul 23, 2003 at 08:41 UTC
    The 'trick' is to know that most internet protocols require lines to be separated by CRLF. According to RFC 2822 (Internet Message Format):
    Messages are divided into lines of characters. A line is a series of +characters that is delimited with the two characters carriage-return +and line-feed; that is, the carriage return (CR) character (ASCII val +ue 13) followed immediately by the line feed (LF) character (ASCII va +lue 10). (The carriage-return/line-feed pair is usually written in t +his document as "CRLF".)
    CRLF is \015\012, note that \n cannot be relied on to always be a newline.

    C.

      Thanks for the information about CRLF, but I'm not quite sure how to actually send these characters. Simply sending them in ASCII text as "\015\012" in the e-mail doesn't work, and they are interpreted as that string. I've searched around this and other sites and have found no answer yet. How can I send them so they are interpreted as a CRLF?
        That should work.. (It's how CRLF is defined in Socket.pm) - Maybe you should post some of your code so we can see exactly what you're doing?

        C.