in reply to e-mail with newlines

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.

Replies are listed 'Best First'.
Re: Re: e-mail with newlines
by lpoht (Sexton) on Jul 24, 2003 at 06:32 UTC
    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.

        Good idea. Here is the block of code:
        $message =~ s/<REQUEST>/$requests/i; $sitecfg{SUBJECT}=~s/<NAME>/$htmlparams{name}/i; my %mail = ( To => $sitecfg{REMAIL}, From => ($sitecfg{MAILFROM} || $htmlparams{email}), Subject => ($sitecfg{SUBJECT} || "Data Request"), Message => $message, ); $mail{smtp}=[qw(localhost earth.co-ra.com)]; $mail{retries}=$sitecfg{RETRIES}; sendmail(%mail);
        Basically, the code reads a message from a configuration file. In the message read are a few tags, such as <REQUEST>. Before this block, the code gathers some data and puts it in the message with the search/replace command. The message text is something like:
        Here is the data you requested:\015\012<REQUEST>\015\012Data collected + on...
        As I mentioned, when the message arrives in my inbox, the CRLF appears in text as "\015\012"