|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-07-14 23:51 UTC] jjohnson at salesteamautomation dot com
Description:
------------
We're having a problem with mail and str_replace. If we use str_replace on certain emails before sending them, we get extra characters in the email that is sent. Right before sending, the email looks fine. When it is received, however, it has extra characters. If str_replace is not used, the received email does not have extra characters.
Reproduce code:
---------------
$content_template = '<html><head></head><body><DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt "> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Web only - $1,100 per year<o:p></o:p></SPAN></FONT></SPAN>
<DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt "> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Phone only - $1,300 per year<o:p></o:p></SPAN></FONT></SPAN>
<DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt "> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Both - $1,500 per year<o:p></o:p></SPAN></FONT></SPAN>
<DT class=MsoNormal style="TEXT-INDENT: 0.5in"><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">*There is a one time set-up fee of $499 which we will waive with a three year agreement.</SPAN></FONT></body></html>';
$content = "? Web only - $1,100 per year ".
"? Phone only - $1,300 per year ".
"? Both - $1,500 per year ".
"*There is a one time set-up fee of $499 which we will waive with a three
year agreement. ";
class EmailTest{
function EmailTest($email_from, $email_to, $subject, $content_template, $content){
$this->email_from = $email_from;
$this->email_to = $email_to;
$this->subject = $subject;
$this->content = $content;
$this->content_template = $content_template;
}
}
$email =& new EmailTest( "jjohnson@salesteamautomation.com", "jjohnson@salesteamautomation.com", "SilentWhistle Follow-up", $content_template, $content);
$email->content_template = str_replace("\n",'',$email->content_template);
$email->content = str_replace('', '', $email->content_template);
$email->content = $email->content_template;
$header = "MIME-Version: 1.0\nContent-Type: text/html; charset=iso-8859-1\n";
$result = mail($email->email_to, $email->subject, $email->content, $header, '');
Expected result:
----------------
This is the expected email:
? Web only - $1,100 per year
? Phone only - $1,300 per year
? Both - $1,500 per year
*There is a one time set-up fee of $499 which we will waive with a three year agreement.
This is the html from the expected email:
<html><head></head><body><DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt "> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Web only - $1,100 per year<o:p></o:p></SPAN></FONT></SPAN>
<DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt "> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Phone only - $1,300 per year<o:p></o:p></SPAN></FONT></SPAN>
<DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt "> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Both - $1,500 per year<o:p></o:p></SPAN></FONT></SPAN>
<DT class=MsoNormal style="TEXT-INDENT: 0.5in"><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">*There is a one time set-up fee of $499 which we will waive with a three year agreement.</SPAN></FONT></body></html>
Actual result:
--------------
This is the received email:
? Web only - $1,100 per year
? ; Phone only - $1,300 per year
? Both - $1,500 per year
*There is a one time set-up fee of $499 which we will waive with a three year agreement.
This is the html from the received email:
<html><head></head><body><DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt "> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Web only - $1,100 per year<o:p></o:p></SPAN></FONT></SPAN>
<DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt "> 
; </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Phone only - $1,300 per year<o:p></o:p></SPAN></FONT></SPAN>
<DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt "> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Both - $1,500 per year<o:p></o:p></SPAN></FONT></SPAN>
<DT class=MsoNormal style="TEXT-INDENT: 0.5in"><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FO
NT-FAMILY: Arial">*There is a one time set-up fee of $499 which we will waive with a three year agreement.</SPAN></FONT></body></html>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 20:00:02 2025 UTC |
Here's the shortest script I can create to replicate the bug. The code is not that long, but it seems to be dependent on the data. I shortened the data as much as I could. $breaks = ' <html><head></head><body> <DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt"> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Phone only - $1,300 per year<o:p></o:p></SPAN></FONT></SPAN> <DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt"> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Both - $1,500 per year<o:p></o:p></SPAN></FONT></SPAN> </body></html> '; $works = ' <html><head></head><body> <DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt"> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Phone only - $1,300 per year<o:p></o:p></SPAN></FONT></SPAN> <DT class=MsoNormal style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo6; tab-stops: list .75in"><FONT face=Symbol size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><SPAN style="mso-list: Ignore">?<FONT face="Times New Roman" size=1><SPAN style="FONT: 7pt"> </SPAN></FONT></SPAN></SPAN></FONT><SPAN dir=ltr><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Both - $1,500 per year<o:p></o:p></SPAN></FONT></SPAN> </body></html> '; $breaks = str_replace("\n",'',$breaks); $header = "MIME-Version: 1.0\nContent-Type: text/html; charset=iso-8859-1\n"; $result = mail("jjohnson@salesteamautomation.com", 'breaks', $breaks, $header, ''); $result = mail("jjohnson@salesteamautomation.com", 'works', $works, $header, '');