Jump to content

PHP Mail() HTML -- Sending as PLAIN TEXT


Matthew2000

Recommended Posts

Folks,

I have sent many emails over the years with PHP and never had an HTML problem. I launched a new Apache/PHP server the other day and emails send fine.

All emails send as plain text. Seems like the encoding isn't working.

Even with the:

$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

Being set... the email sending is not HTML, but plain text.

I can take this same PHP script and run it on another server and I get an HTML email.

So I know my PHP script is correct. What server setting in PHP/Apache would cause all emails to be sent as plain text ?

Here is what the recipient receives on their end in the message area of the text email:

Content-type: text/html; charset=iso-8859-1

From: no-reply@yahoo.com
Message-Id: <20180909154528.C4128612EC@ww1.localdomain>
Date: Sun,  9 Sep 2018 11:45:28 -0400 (EDT)

<html><body><h1>Hello, World!</h1></body></html>

My script code:

$to = 'test99@domain.com';
$subject = 'php test';

$from='no-reply@yahoo.com';

$headers ='';
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$from.' '. "\r\n";

$message = '<html><body>';
$message .= '<h1>Hello, World!</h1>';
$message .= '</body></html>';

mail($to, $subject, $message, $headers);
Link to comment
Share on other sites

If they're seeing stuff like the Message-Id in the message area then it's the sendmail client on your server that's messed up. Ask your hosting provider to look into it. You should send them an example of the full message as received by the client's (I suggest yours for this) mail server, for example what Gmail's "Show original" does.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.