Send Emails using PHP mail() Function
Sending email messages is very common for a web application. You can use the PHP built-in mail() function for creating and sending email messages to one or more recipients dynamically from your PHP application either in a plain-text form or formatted HTML. In below code u will see how to send email message in table format.
The basic syntax of the mail() function can be given with:
mail(to, subject, message, headers, parameters)
<?php
if (isset($_POST['submit'])) {
$name = $_POST["name"];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['message'];
$subject = "Contact Page | Solanki Tea";
$message = "Dear Team,";
$message .= "You have recieved one notification from Contact Page. Details are as follows";
$message .= "<br><br>";
$message .= "<table width='80%' style='border: 1px solid #dfdfdf; border-collapse: collapse;'>";
$message .= "<tr style='background: #f5f5f5;'><td style='padding: 10px 5px; border: 1px solid #dfdfdf; width: 15%;'>Name</td><td style='padding: 10px 5px; border: 1px solid #dfdfdf; width: 85%;'>$name</td></tr>";
$message .= "<tr style='background: #f5f5f5;'><td style='padding: 10px 5px; border: 1px solid #dfdfdf; width: 15%;'>Email</td><td style='padding: 10px 5px; border: 1px solid #dfdfdf; width: 85%;'>$email</td></tr>";
$message .= "<tr style='background: #f5f5f5;'><td style='padding: 10px 5px; border: 1px solid #dfdfdf; width: 15%;'>Mobile</td><td style='padding: 10px 5px; border: 1px solid #dfdfdf; width: 85%;'>$phone</td></tr>";
$message .= "<tr style='background: #f5f5f5;'><td style='padding: 10px 5px; border: 1px solid #dfdfdf; width: 15%;'>Message</td><td style='padding: 10px 5px; border: 1px solid #dfdfdf; width: 85%;'>$address</td></tr>";
$message .= "</table>";
$to = '[email protected]';
$header = "From:[email protected] \r\n";
$header .= "Cc:[email protected]\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
echo "Sent Message";
}