|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-07-07 22:15 UTC] jani@php.net
[2009-07-15 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 01:00:01 2025 UTC |
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--