Call Now
Quick Inquiry

How to Send Text and HTML Emails in PHP- PHP Email Code Example

How to Send Text and HTML Emails in PHP- PHP Email Code Example

PHP Send Emails in HTML Formate

(How to Send Text and HTML Emails in PHP- PHP Email Code Example.using this example of code you can send easily mail in well formatted of html table.just you need to copy the entire code and paste inside your file)

Mail Example code:-

<form action="#" class="contact-form">
                            <div class="row m-0">
                                <div class="col-12 p-0">
                                    <input type="text" name="name" placeholder="Fullname" class="form-control">
                                <div class="col-12 p-0">
                                    <input type="text" name="number" placeholder="Your Number" class="form-control">
                                <div class="col-12 p-0">
                                    <input type="email" name="email" placeholder="Email" class="form-control">
                                <div class="col-12 p-0" >
                                    <div class="form-control">
                                    <label for="cars"> <b>Choose Options:-</b></label>
                                      <select name="cars" id="cars" required="">
                                        <option value="" hidden><b> PURPOSE </b></option>
                                        <option value="Partnership">Partnership</option>
                                        <option value="Services">Services</option>
                                        <option value="Pricing">Pricing</option>
                                        <option value="For business">For business</option>
                                        <option value="Other">Other</option>
                                <div class="col-12 p-0">
                                    <textarea name="message" id="" rows="6" class="form-control" placeholder="Message"></textarea>
                                <div class="col-12 p-0 text-right">
                                    <button type="submit" name="sendInquiry" class="btn btn-primary">Submit</button>

                               $to = ''; 
                                $from = $_REQUEST["email"]; 
                                $fromName = $_REQUEST["name"]; 
                                $subject = "Your Website Enquiry ".Date("D-m-Y"); 
                                $htmlContent = ' 
                                        <title>Welcome to Trimwebsolutions</title> 
                                        <h1>Thanks you for joining with us!</h1> 
                                        <table cellspacing="0" style="border: 2px dashed #FB4314; width: 100%;"> 
                                            <tr style="background-color: #e0e0e0;"> 
                                            <tr style="background-color: #e0e0e0;"> 
                                            <tr style="background-color: #e0e0e0;"> 
                                            <tr style="background-color: #e0e0e0;"> 
                                                <th>Website:</th><td><a href=""></a></td> 
                                // 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: '.$fromName.'<'.$from.'>' . "\r\n"; 
                                $headers .= 'Cc:' . "\r\n"; 
                                $headers .= 'Bcc:' . "\r\n"; 
                                // Send email 
                                if(mail($to, $subject, $htmlContent, $headers)){ 
                                    echo 'Email has sent successfully.'; 
                                   echo '<font color="green">Email sending failed.</font>'; 

827 0

Write a Comments

* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online