Amazon.in Widgets Send Email With HTML Template - Er Vinay Singh

Send Email With HTML Template

Send Email With HTML Template

If you send a textual content message utilizing PHP then all of the content material will probably be handled as easy textual content. Even when you’ll include HTML tags in a textual content message, will probably be displayed as easy textual content and HTML tags won’t be formatted according to HTML syntax. However PHP supplies choice to ship an HTML message as actual HTML message.

To send mail in HTML format you can specify a Mime version.

<?php
$to = 'example@gmail.com';
$subject = "Query From example.com";

$visitor_email =$_POST['email'];
$name = $_POST['name'];
$mobile = $_POST['mobile'];
$message = $_POST['message'];
//echo $visitor_email;
//die;
			
		
$htmlContent = '
   <html>
    <head>   
    </head>
   <body style="background-color:#f9f9f9; padding: 15px;" >   
    <a href="http://example.com/" target="_blank"><img src="#" border="0"></a>
        <h2>Hi Admin,</h2>
        <h3>One of your customer has enquired with following details !</h3>
        <table cellspacing="0">
           <tr>
           <td>'.$name.'</td>
           </tr>
           <tr>
           <td>'.$visitor_email.'</td>
           </tr>
           <tr>
           <td>'.$mobile.'</td>
           </tr>
           <tr>
           <td>'.$message.'</td>
           </tr>
        </table>
       <h4><strong>Thanks & Regards </strong></h4> 
       '.$name.'
       </br></br>
       
    </body>
    </html>';

// Set content-type header for sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// Additional headers
$headers .= 'From:example@gmail.com<info@example.com>' . "\r\n";
$headers .= 'Cc: example@gmail.com' . "\r\n";
//$headers .= 'Bcc: welcome2@example.com' . "\r\n";

// Send email
if(mail($to,$subject,$htmlContent,$headers)):
           
           //header ('location:index.php');
         echo "<script>
alert('Thank You,Email Sent Successfully. We will get back to you within 24 hrs.');
window.location.href='index.php';
</script>";
else:
            echo "<script type='text/javascript'>alert('Faild!')</script>";
endif;
?>

Leave a Comment