-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail.php
66 lines (60 loc) · 2.42 KB
/
mail.php
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
60
61
62
63
64
65
66
<?php
if(isset($_POST['submit']))
{
$name = $_POST['name']; // Get Name value from HTML Form
$name2 = $_POST['name2']; // Get Name value from HTML Form
$email_id = $_POST['email']; // Get Email Value
$mobile_no = $_POST['contactNumber']; // Get Mobile No
$msg = $_POST['message']; // Get Message Value
$to = "[email protected]"; // You can change here your Email
$subject = "'$name' has sent a mail"; // This is your subject
// HTML Message Starts here
$message ="
<html>
<body>
<table style='width:600px;'>
<tbody>
<tr>
<td style='width:150px'><strong>Name: </strong></td>
<td style='width:400px'>$name</td>
</tr>
<tr>
<td style='width:150px'><strong>Last Name: </strong></td>
<td style='width:400px'>$name2</td>
</tr>
<tr>
<td style='width:150px'><strong>Email ID: </strong></td>
<td style='width:400px'>$email_id</td>
</tr>
<tr>
<td style='width:150px'><strong>Mobile No: </strong></td>
<td style='width:400px'>$mobile_no</td>
</tr>
<tr>
<td style='width:150px'><strong>Message: </strong></td>
<td style='width:400px'>$msg</td>
</tr>
</tbody>
</table>
</body>
</html>
";
// HTML Message Ends here
// 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
if(mail($to,$subject,$message,$headers)){
// Message if mail has been sent
echo "<script>";
echo 'window.location= "../contact.html?message=sent";';
echo "</script>";
}
else{
// Message if mail has been not sent
echo "<script>";
echo 'window.location= "../contact.html?message=error";';
echo "</script>";
}
}
?>