Category Covered

How to send HTML format emails in wordpress

First You may want to specify the admin email address where all the registered users information should redirect.

To do this you need to specify the wordpress  admin email address in your variable or you can give a certain email id also.



Remember  here the default content type is 'text/plain' which is not supported in using HTML.  You need to set the content type of the email as 'wp_mail_content_type' .
Follow the example code:

<?php $to = get_bloginfo('admin_email');// or myeamil@test.com

$subject = "User Registration for My sample Website";
$message = '<table width="400" border="0" >
   <tr>
      <td>First Name</td>
      <td>'.$first_name.'</td>
   </tr>
   <tr>
         <td>Last Name</td>
         <td>'.$last_name.'</td>
    </tr>
    <tr>
         <td>Email</td>
         <td>'.$email.'</td>
     </tr>
     <tr>
        <td>Phone</td>
        <td>'.$phone.'</td>
    </tr>
</table>';
?>
<?php
  function wpse_set_content_type(){
     return "text/html";
  }
  add_filter( 'wp_mail_content_type','wpse_set_content_type' );
  $headers = 'From: "Registration" <'.$email.'>';
  wp_mail( $to, $subject, $message, $headers);
?>

Now you can easily send your registerd user email in to your wordpress site admin address or your email address in HTML formate.