|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13044 unexpected characters in mail
Submitted: 2001-08-29 16:12 UTC Modified: 2002-04-19 00:00 UTC
Avg. Score:4.3 ± 0.8
Reproduced:42 of 42 (100.0%)
Same Version:10 (23.8%)
Same OS:12 (28.6%)
From: michalprv at poland dot com Assigned:
Status: No Feedback Package: Mail related
PHP Version: 4.0.6 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2001-08-29 16:12 UTC] michalprv at poland dot com
$sql = "Long line: 123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890123456789012345678901234568901234567890";
mail($address, $subject, $sql);

In this case the mail function isn't working properly. When the string line ist too long, unexpected characters are inserted (this is "!/n")


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-18 10:50 UTC] beteulgeuseNOSPAM at hotmail dot com
got this bug on
linux debian 2.2.17 potato
php 4.0.1pl2

more info about the number of characters.
990 characters is fine,
991 is bad, and "!\n" appears on the 990 position.

good luck :-)
 [2002-03-18 10:57 UTC]
Works fine for me... what mail program do you use?

 [2002-03-18 11:03 UTC]
I'ld suggest to try with a newer PHP version anyway.
 [2002-04-19 00:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2005-04-22 08:46 UTC] wehaveagig at hotmail dot com
I'm a web developer and I've been experiencing a very similar problem. Infact, it almost identical to the problem reported in Bug #31496 (I would have added my comment there, but I couldn't do so because it was listed as "Bogus"). 

But in my case, the problem is INTERMITTENT, where the garbage exclamation point character ! will appear in different places in a given message. (If it occurs at all). Sometimes the messages will be prefectly fine. Other times, I'll get an exclamation point somewhere in the body of the message. And other times, there will be several exclamation points in a given message.

I strongly suspected the Zend Optimizer causing these bugs, as it tries to look ahead, it may be invoking the mail/sendmail program inproperly or before the message has finished being fully formed.

Please respond with any opinions on that theory. Thanks

 [2007-07-30 17:46 UTC] brieb at kreotek dot com
I am using a standard Ubuntu 6.06 Dapper Drake installation (PHP 5.1.2, Postfix ,and Apache 2.0.55 (unbutu)) and am having similar problems. 

extra characters are are very consistent, and all emails with too-long lines are getting that "!/n" characters put in.
 [2007-08-14 19:14 UTC] kinadian at cogeco dot ca
I ran into this same problem.  I was able to fix it by adding in newline characters.  From what I can determine, it is caused by too many characters on one line.

In my case, I was sending an HTML e-mail and I didn't bother with newlines because I was using HTML formatting.

By adding newline characters (I added them where I would if I were creating a nicely formated HTML webpage) I was able to avoid this bug.

I hope this helps you guys too.
 [2008-03-18 09:04 UTC] michael dot reiter at univr dot it
I have this problem with PHP 5.2.5.
Seems that when the message exceeds a certain length it adds strange characters (</p> in the message, splits a word with a space character, ...)
 [2008-03-18 11:28 UTC] michael dot reiter at univr dot it
I had several links in my HTML email. The effect described above could be resolved by adding the target attribute to the link. 

Note that exactly the same HTML would be correct and would bring no error within browsers. This effect only applies to HTML emails sent with the PHP mail() function.

<a href="url">text</a> 
in some emails causes the characters <p> to be inserted at the end of paragraphs or spaces to be inserted within words (splitting them up) in the subsequent html

<a href="url" target="_self">text</a> (also target="_blank" or whatever)
does not bring this effect
 [2008-04-07 20:45 UTC] ryan dot morrow at gmail dot com
I was having a similar problem sending the Content-Type: text/html through the php mail() function.  Extra spaces were being inserted almost randomly.  If I added text, the space would move down the number of spaces I added.

I was pulling the HTML from a database, and everything was inserted on a single line.  Inserting newlines corrected the problem.
 [2008-04-15 13:35 UTC] indeyets at gmail dot com
This is a standard limit of sendmail/smtp. See here for details:

Solution is to use base64-encoding
 [2012-02-29 05:02 UTC] brendan at brendanenglish dot com
Try using 'wordwrap' when sending the message, this should break up the email and 
fix the issue:

@mail($to, $subject, wordwrap($message), $headers);
 [2017-02-06 12:01 UTC] kumarsher45 at gmail dot com
Thanks! :)
 [2017-05-10 09:58 UTC] wankhede1988 at gmail dot com
Similar case was with me, when i was printing email on console, it was not showing any spacial characters, but in outlook mail is was displaying unwanted characters like (!).
after using wordwrap() to mail body.

thanks for hint :)
 [2017-09-04 03:45 UTC] yhl_totti at 163 dot com
The text is too long, you can add a "\n" after the <tr>,similar to the function of wordwrap
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 12 11:01:32 2024 UTC