#48841 [Opn->Fbk]: A tab inside ob_start using Eclipse IDE causes a glitch when sending HTML email

From: Date: Tue, 07 Jul 2009 22:15:19 +0000
Subject: #48841 [Opn->Fbk]: A tab inside ob_start using Eclipse IDE causes a glitch when sending HTML email
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-139449@lists.php.net to get a copy of this message
 ID:               48841
 Updated by:       jani@php.net
 Reported By:      jason dot anderson at abcphones dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Scripting Engine problem
 Operating System: Windows XP
 PHP Version:      5.3.0
 New Comment:

Does this work with PHP 5.2.10 ?


Previous Comments:
------------------------------------------------------------------------

[2009-07-07 21:13:39] 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--



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48841&edit=1



Thread (2 messages)

« previous php.bugs (#139449) next »