-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmail.php
51 lines (35 loc) · 1.64 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
<?php
// Put contacting email here
$php_main_email = "[email protected]";
//Fetching Values from URL
$php_name = $_POST['ajax_name'];
$php_email = $_POST['ajax_email'];
$php_message = $_POST['ajax_message'];
//Sanitizing email
$php_email = filter_var($php_email, FILTER_SANITIZE_EMAIL);
//After sanitization Validation is performed
if (filter_var($php_email, FILTER_VALIDATE_EMAIL)) {
$php_subject = "Message from contact form";
// To send HTML mail, the Content-type header must be set
$php_headers = 'MIME-Version: 1.0' . "\r\n";
$php_headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$php_headers .= 'From:' . $php_email. "\r\n"; // Sender's Email
$php_headers .= 'Cc:' . $php_email. "\r\n"; // Carbon copy to Sender
$php_template = '<div style="padding:50px;">Hello ' . $php_name . ',<br/>'
. 'Thank you for contacting us.<br/><br/>'
. '<strong style="color:#f00a77;">Name:</strong> ' . $php_name . '<br/>'
. '<strong style="color:#f00a77;">Email:</strong> ' . $php_email . '<br/>'
. '<strong style="color:#f00a77;">Message:</strong> ' . $php_message . '<br/><br/>'
. 'This is a Contact Confirmation mail.'
. '<br/>'
. 'We will contact you as soon as possible .</div>';
$php_sendmessage = "<div style=\"background-color:#f5f5f5; color:#333;\">" . $php_template . "</div>";
// message lines should not exceed 70 characters (PHP rule), so wrap it
$php_sendmessage = wordwrap($php_sendmessage, 70);
// Send mail by PHP Mail Function
mail($php_main_email, $php_subject, $php_sendmessage, $php_headers);
echo "";
} else {
echo "<span class='contact_error'>* Invalid email *</span>";
}
?>