ID:               48841
 Updated by:       [email protected]
 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 = '[email protected]';
$subject = 'My Code';
$random_hash = md5(date('r', time()));
$headers = "From: [email protected]\r\nreply-to: [email protected]";
$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

Reply via email to