-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend.php
executable file
·39 lines (35 loc) · 1.45 KB
/
send.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
<!--WORK IN PROGRESS-->
<?php
SESSION_START();
// Checking For Blank Fields..
if($_POST["realname"]==""||$_POST["email"]==""||$_POST["subject"]==""||$_POST["message"]==""){
$_SESSION['result']="Not all fields have been filled out...";
}else{
// Check if the "Sender's Email" input field is filled out correctly
$email=$_POST['email'];
// Sanitize E-mail Address
$emailCheck=filter_var($email, FILTER_SANITIZE_EMAIL);
// Validate E-mail Address
$emailCheck=filter_var($email, FILTER_VALIDATE_EMAIL);
if (!($emailCheck)){
$_SESSION['result']="Failed to validate email address...";
}else{
$subjectMatter = $_POST['subject'];
$subject = '[WEBSITE_MAIL] '.$email.' || '.$subjectMatter;
$message = $_POST['message'];
$realname = $_POST['realname'];
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/plain; charset=utf-8';
$headers[] = 'From: '.$realname.'<[email protected]>';
// Message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// Send Mail By PHP Mail Function
if(mail("[email protected]", $subject, $message, implode('\r\n', $headers))){
$_SESSION['result']="Email was send successfully!<br>I will reply as soon as I can!<br>(Replies could get marked as spam)";
}else{
$_SESSION['result']="Error: Failed to send email...";
}
}
header("Location: http://www.paulsohns.com/contact.php");
}
?>