I'm experiencing a weird problem with PHP's mail function that I just can't figure out. Each line in the email body is separated by a new line or two but if I use a ternary operator on one of the lines, the line does not break. The code looks something like this:
$body = 'This line breaks properly' . "
" .
'This line also breaks properly' . "
" .
'This one as well' . "
" .
'This line ' . ( $value == true ? 'breaks' : 'does not break' ) . ' properly' . "
" .
'This one works fine' . "
" .
'New line again';
mail( 'me@example.com', 'Test Email', $body, $headers );
The output I get is:
This line breaks properly
This line also breaks properly
This one as well
This line does not break properly This one works fine
New line again
I've double and triple checked to make sure I put double quotes around each
, I tried ( $value == true )
within the ternary, and I've tried setting Content-Type: text/plain;
in the header string. It only works when I completely removed the ternary operator. I'm using PHP 5.5.36 if that has any relevance to what's going on.