Special characters added in Email rending in Outlook

the mail() function

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 215
Joined: Wed Dec 07, 2011 5:25 pm

Sun Jan 29, 2012 1:22 pm

Hello Meher K Bala.
I changed your encoding to UTF-8(line no: 47 and 48)
Should work and Should handle correctly:

Code: Select all

$to ='test@open-source-varsity.com';

$subject = "Testing";

$message = '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>' . $subject . '</title></head>
<body style="font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; font-size: 10pt;">
   <fieldset style="width:700px;">
      <legend>&nbsp; <strong>Personal Information</strong> &nbsp;</legend>
      <table width="100%" cellspacing="0" border="1" cellpadding="5" align="left">
            <td align="right" style="font-size: 10pt;" width="30%"><strong>Title:</strong></td>
            <td align="left" style="font-size: 10pt;" width="70%">'.$m_title.' </td>
            <td align="right" style="font-size: 10pt;" width="30%"><strong>First Name:</strong></td>
            <td align="left" style="font-size: 10pt;" width="70%">'.$m_fname.' </td>
            <td align="right" style="font-size: 10pt;" width="30%"><strong>Middle Name:</strong></td>
            <td align="left" style="font-size: 10pt;" width="70%">'.$m_mname.' </td>
            <td align="right" style="font-size: 10pt;" width="30%"><strong>Last Name:</strong></td>
            <td align="left" style="font-size: 10pt;" width="70%">'.$m_lname.' </td>
            <td align="right" style="font-size: 10pt;" width="30%"><strong>Address:</strong></td>
            <td align="left" style="font-size: 10pt;" width="70%">'.$m_address.' </td>
            <td align="right" style="font-size: 10pt;" width="30%"><strong>Email Address:</strong></td>
            <td align="left" style="font-size: 10pt;" width="70%">'.$m_email_id.' </td>
            <td align="right" style="font-size: 10pt;" width="30%"><strong>Confirm Email Address:</strong></td>
            <td align="left" style="font-size: 10pt;" width="70%">'.$m_confirm_email_id.' </td>
   <div class="divClr" style="clear:both;">&nbsp;</div>

/* To send HTML mail, set the Content-type header. */
$headers = "MIME-Version: 1.0". PHP_EOL;
$headers .= "Content-type: text/html; charset=UTF-8" . PHP_EOL;

/* additional headers */
$headers .= "To: " . $to ." \n";

/* and now mail it */
if(mail($to, $subject, $message, $headers))
   $status = "Sent";

Post Reply