This repository has been archived by the owner on May 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail-handler.php
66 lines (58 loc) · 1.76 KB
/
mail-handler.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($_POST["contact-project"]) {
$headers = "From: " . $_POST["contact-email"] . "\r\n";
$headers .= "Content-type:text/plain" . "\r\n";
mail("[email protected]", "Portfolio Homepage 2022", $_POST["contact-project"], $headers);
} */
// echo 'vor mailpruefung' . '<br>';
$errors = '';
$myemail = '[email protected]';//<-----Put Your email address here.
if(empty($_POST['contact-name']) ||
empty($_POST['contact-email']) ||
empty($_POST['contact-project']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['contact-name'];
$email_address = $_POST['contact-email'];
$message = $_POST['contact-project'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
//echo 'vor mailversand';
if( empty($errors))
{
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $name \n ".
"Email: $email_address\n Message \n $message";
$headers = "From: $myemail\r\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Content-Type: text/html');
header('Referrer Policy: unsafe-url, no-referrer');
header('Location: https://d3rklabauter.github.io/index.html');
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset=UTF-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Contact form handler</title>
</head>
<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
echo 'servas body';
?>
</body>
</html>