Simple HTML Email Template in PHP

Here is the code for a simple basic HTML e-mail template that can be sent within php.

The user will receive the e-mail in html format, he will see images as well. You can also put as you see text elements like strong, ul etc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
 
if (!empty($_POST['telephone_nr'])){
$full_name = $_POST['full_name'];
$company = $_POST['company'];
$email = $_POST['email'];
$telephone = $_POST['telephone_nr'];
$offer_price = $_POST['offer_price'];
$zip_code = $_POST['zip_code'];
$comments = $_POST['comments'];
 
$url = $_POST['url'];
 
$to = 'admin@incvice.com';
$subject = '!NEW email from incvice.com';
 
$message = '
<html>
<head>
<title>Request</title>
</head>
<body>
<p><strong>A person has made a quote request for this item:</strong><br>
'.$url.'<br><br>
 
 
Full Name: '.$full_name.'<br>
Company: '.$company.'<br>
Email: '.$email.'<br>
Telephone: '.$telephone.'<br>
Offered Price: '.$offer_price.'<br>
Zip Code: '.$zip_code.'<br>
Additional Comments: '.$comments.'<br><br>
 
</p>
<br><br>
</body>
</html>
';
 
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
 
// More headers
$headers .= 'From: <admin@incvice.com>' . "\r\n";
$headers .= 'Cc: admin@incvice.com' . "\r\n";
 
$mail = mail($to, $subject, $message, $headers);
 
echo'<script language="Javascript">
<!--
alert ("Thank you very much, we have received your quote request and we will reply ASAP.")
history.go(-1);
-->
</script>';  
 
}
?>

ADD A COMMENT: