I have the following code:
$subject = "Test Email";
$from = "[email protected]";
ini_set("sendmail_from", $from);
$message = "<html><body bgcolor=\"#DCEEFC\">
Hello<br><br>
This is a <b>test</b> email.
<br><br><hr>
<a href=\"\">Click Here</a>
<br><br><hr>
<br><br>
Thank you for your time,<br><br>
</body></html>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html\r\n";
$headers .= "From: " . $from . "\r\n";
mail($mail, $subject, $message, $headers);
However, when I send the email to myself, I see all the code in Outlook. If i send it to someone else, They see the HTML. If i send it to my hotmail, they see the HTML.
Is this a problem with my outlook (2007), if so, what is it, or can I do something in the email to guarantee it being displayed properly?
Please help!
Copied! Copied! If your website or web application is built on PHP, you can utilize the PHP mail feature to send emails. It can come in handy for creating custom-built mail forms and sending simple text-based email messages.
PHPMailer is a popular mail sending library for PHP. It supports mail sending via mail() function or Simple Mail Transfer Protocol . This library simplifies the complicated process of building a PHP mail by providing a set of functions to create and send an email. Installing PHPMailer is quite simple, especially if you have Composer installed.
Note: Keep in mind that even if the email was accepted for delivery, it does NOT mean the email is actually sent and received! PHP 5.4: Added header injection protection for the headers parameter. PHP 4.3.0: (Windows only) All custom headers (like From, Cc, Bcc and Date) are supported, and are not case-sensitive.
The mail() function in PHP allows sending email using a local sendmail program. Whenever you call the mail() function, it invokes a local sendmail program, usually configured by the system administrator.
Try to reorder the header. I remember having the same problem a while ago and it worked after I used the following headers:
$headers = "From: " .$from. "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
I would recommend though to use a ready-to-go php mailer class - it makes life much easier.
I found the problem:
HTML Email not displaying correctly for Godaddy web based mail
Changed:
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html\r\n";
$headers .= "From: " . $from . "\r\n";
to:
$headers = "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-Type: text/html; charset=ISO-8859-1" . PHP_EOL;
$headers .= "From: Site<$from>" . PHP_EOL;
Thanks for all your help guys! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With