仅在以下电子邮件中发生这种情况: post@domain.com(使用交换)。联系表单适用于gmail ......?
源代码:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$from = 'From website';
$headers = "From: post@domain.com\r\n";
$headers .= "Reply-To: post@domain.com\r\n";
if ($_POST['avdeling'] == "avdeling1") {
$subject = 'To person 1';
$to = "Person1@domain.com";
} else if ($_POST['avdeling'] == "avdeling2") {
$subject = 'To person 2';
$to = "Person2@domain.com";
} else if ($_POST['avdeling'] == "avdeling3") {
$subject = 'To person 3';
$to = "Person3@domain.com";
} else if ($_POST['avdeling'] == "avdeling4") {
$subject = 'To person 4';
$to = "Person4@domain.com";
} else{
$subject = 'To post';
$to = "post@domain.com";
}
$body = "name: $name\n Email: $email\n message:\n $message \n Phone: $phone";
?>
<?php
if (isset($_POST['submit'])) {
if (mail($to, $subject, $body, $from)) {
header("Location:domain.com");
} else {
echo '<p>Error. Try again!</p>';
}
}
?>