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

Mighty monks, I have an intranet running that sends emails to the registered users. I decided to change from a plain text to html. OOPS. I discovered that when a line is sent to an email client that is too long it breaks the line and inserts a ! (exclamation point). This doesn't happen when you edit the email on the screen. And it too, is html. So what is going on? Is this something I don't get about sendmail? It's really the dumbest thing. All I do is read a file with the text of the email, assign it to $message and replace any \n with <BR> and enclose the whole thing in <SPAN class=md> tag. Too weird. What should I do. Your everfaithful baby monk, Uncle Ron

Replies are listed 'Best First'.
Re: Line too long for email
by Juerd (Abbot) on Mar 07, 2004 at 22:03 UTC

    I discovered that when a line is sent to an email client that is too long it breaks the line and inserts a ! (exclamation point).

    What is inserting this? Find that out and you know where to change something. Without that information, nobody can help you.

    Note that in email, lines MUST be no longer than 998 characters, excluding CRLF. See section 2.1.1 of RFC 2822. Possibly something is breaking lines to avoid breaking rules, and inserting exclamation points as a visual mark.

    If this is indeed the problem, use quoted printable encoding to fix it. MIME::QuotedPrint can help you with that.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Re: Line too long for email
by hossman (Prior) on Mar 07, 2004 at 23:22 UTC

    Unless you have a compelling reason to care where the "!" is coming from, change this....

    ... assign it to $message and replace any \n with <BR> and enclose the whole thing in ...

    ...to this...

    ... assign it to $message and replace any \n with \n<BR> and enclose the whole thing in ...

      \n<br>

      Although it doesn't matter at all, I just want to say that <br>\n more common.

      Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Re: Line too long for email
by exussum0 (Vicar) on Mar 07, 2004 at 22:06 UTC
    I decided to change from a plain text to html. OOPS. I discovered that when a line is sent to an email client that is too long it breaks the line and inserts a ! (exclamation point). This doesn't happen when you edit the email on the screen.
    Email is a finicky thing. Some clients, like AOL didn't used to split html and text content. If you sent a multi-mime mail with text/html and text/plain, AOL viewers would get both. pegasus email users would get weird hard wrapping or something.

    I suggest using something like outlook or thunderbird, maybe even eudora or pine, to test this. I know for a fact, that you won't get that weird issue unless ..

    a. you insert the ! yourself
    b. a server inbetween is out to get you, doing it itself.

      Those are crappy Email clients, but they're not Email.
Re: Line too long for email
by Hagbone (Monk) on Mar 08, 2004 at 00:18 UTC
    This is interesting ... I seem to remember running into a similar problem quite a while ago, and I **think** the problem was caused by the placement order of the HTML <form> tag.

    I know this sounds crazy, but I swear that I got rid of the exclamation point by rearranging the placement of "method=" call. In other words, *one* of the below arrangements produced output without the exclamation point, and the other produced output with the exclamation point.

    <form action="/path/to/script.pl" method="POST">

    <form method="POST" action="/path/to/script.pl">

    At any rate, it's not a tough thing to try, and if my recollection is correct, the next question would be why does this make a difference ... if my memory is incorrect ... well, I just hope I don't get slammed too hard for this post.

    3/12 ...... ooooopps

    Just happened to be in a spot to test the above, and what I suggested above is *not* correct. What I've found is that when a line/string (no newline/returns) reaches 989 characters (including spaces), the exclamation point appears. I'm betting one of the smarter monks knows why, but sorry to say I don't ... I'm thinking it might have to do with a maximum allowable string size in sendmail? ... I've never observed it in anything but form email output.