PHP Send HTML Email Table Format Template

PHP Send HTML Email Table Format Template

Today, We want to share with you PHP Send HTML Email Table Format Template.
In this post we will show you PHP Send HTML Email with Table Format, hear for Send Beautiful HTML Email using PHP we will give you demo and example for implement.
In this post, we will learn about how to send email in php with html format with an example.

in this post will show you how to PHP Send HTML Email with Table Format example

require 'include/config.php';

$NewDate=Date('M j, Y', strtotime("+15 days"));
$sql = "SELECT * FROM mtto";
$result = $conn->query($sql);


$to = "[email protected]";
//$to = "[email protected]";
$subject = "Dreams pakainfo Notification";

$message ="Dear ".$to;
$message .= "
<html>
<head>
<title>Dreams pakainfo PHP Get Email With Table</title>
</head>
<body>
<h3>Dreams pakainfo</h3>
<table border='1'>
<tr>
<th>Sr.No</th>
<th>Date</th>
<th>Descripción</th>
<th>Fecha inicial</th>
<th>Periodicidad</th>
<th>F Control 1</th>
<th>F Control 2</th>
<th>F Control 3</th>
</tr>";


if ($result->num_rows > 0) 
{ 
$results = array();
	$i = 1;
	while($row = $result->fetch_assoc()) 
	{
		if($NewDate==$row["fecha_1"] || $NewDate==$row["fecha_2"] || $NewDate==$row["fecha_3"])
		{
			
			 $results[] = $row;
			 $message .="<tr>";
			 $message .="<td>".$i."</td>";
			 $message .="<td>". date("M j, Y", strtotime($row['date_time']))."</td>";
			 $message .="<td>".$row["descr"]."</td>";
			 $message .="<td>".date("M j, Y", strtotime($row['fecha_inicial']))."</td>";
			 $message .="<td>".$row["period"]."</td>";
			 $message .="<td>".$row["fecha_1"]."</td>";
			 $message .="<td>".$row["fecha_2"]."</td>";
			 $message .="<td>".$row["fecha_3"]."</td>";
			 $message .="</tr>";
			//sendemail($row["date"],$row["desrc"],$row["fechaini"],$row["peried"],$row["fecha_1"],$row["fecha_2"],$row["fecha_3"]);
			$i++;
		}
		
	}
}
else 
{
    echo "Not Find Records / 0 results";
}


$message .="</table>
<br/><br/>
	kind Regards<br/>
	Mtto,<br/>
	Mantenimiento.<br/>
</body>
</html>
";
//print_r($results);

//set headers with content-type HTML when sending HTML email in PHP
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// set More headers in PHP
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";

//send Mail Script
mail($to,$subject,$message,$headers);


Related FAQ

Here are some more FAQ related to this Article:

  1.   call javascript function from html
  2.   Enable/Disable debug mode in cakephp
  3.   Jquery Ajax Laravel 5.8 Form Validation
  4.   PHP SQL INNER JOIN Query on Multiple Tables
  5.   Laravel Nested Relationships in Eloquent Example
  6.   PHP Inheritance - Multilevel and Multiple Inheritance in PHP
  7.   [SOLUTIONS] 500 INTERNAL SERVER ERROR PHP
  8.   Laravel Convert object Array JSON String Example
  9.   Dropzone Multiple Image upload validation
  10.   PHP Laravel 6 Change Date Format example