php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48841 A tab inside ob_start using Eclipse IDE causes a glitch when sending HTML email
Submitted: 2009-07-07 21:13 UTC Modified: 2009-07-15 01:00 UTC
From: jason dot anderson at abcphones dot com Assigned: fb-req-jani (profile)
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.3.0 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jason dot anderson at abcphones dot com
New email:
PHP Version: OS:

 

 [2009-07-07 21:13 UTC] jason dot anderson at abcphones dot com
Description:
------------
Using a text editor (Eclipse) for PHP the attached code will not work properly when a tab is typed inside of the ob_start() section.  No errors are reported but when the HTML email is received it is represented as raw text including the header data.  Debugging for this in such case can be very very difficult.

Reproduce code:
---------------
function test_html_email(){
$to = 'jason.anderson@abcphones.com';
$subject = 'My Code';
$random_hash = md5(date('r', time()));
$headers = "From: admin@pgxgolf.com\r\nReply-To: admin@pgxgolf.com";
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
ob_start(); //Turn on output buffering  - Notice tabs below
?>      --PHP-alt-<?php echo $random_hash; ?> 
	Content-Type: text/plain; charset="iso-8859-1"
	Content-Transfer-Encoding: 7bit
	
	Hello World!!! 
	This is simple text email message.
	
	--PHP-alt-<?php echo $random_hash; ?> 
	Content-Type: text/html; charset="iso-8859-1"
	Content-Transfer-Encoding: 7bit
	
	<h2>Hello World!</h2>
	<p>This is something with <b>HTML</b> formatting.</p>
	
	--PHP-alt-<?php echo $random_hash; ?>--
<?php $message = ob_get_clean();
ob_end_flush();
$mail_sent = @mail( $to, $subject, $message, $headers );
echo $mail_sent ? "Mail sent" : "Mail failed";
}
test_html_email();

Expected result:
----------------
Hello World!
This is something with HTML formatting.


Actual result:
--------------
--PHP-alt-527d2deecd08a0f3e80bced5cace8aaa 
	Content-Type: text/plain; charset="iso-8859-1"
	Content-Transfer-Encoding: 7bit
	
	Hello World!!! 
	This is simple text email message.
	
	--PHP-alt-527d2deecd08a0f3e80bced5cace8aaa 
	Content-Type: text/html; charset="iso-8859-1"
	Content-Transfer-Encoding: 7bit
	
	<h2>Hello World!</h2>
	<p>This is something with <b>HTML</b> formatting.</p>
	
	--PHP-alt-527d2deecd08a0f3e80bced5cace8aaa--


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-07 22:15 UTC] jani@php.net
Does this work with PHP 5.2.10 ?
 [2009-07-15 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, 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".
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Sep 28 07:05:52 2022 UTC