当我将电子邮件更改为我的个人 hotmail 地址时,该邮件出现了 - 尽管它在我的垃圾邮件文件夹中。但是当我将其更改为客户的电子邮件时,消息根本没有出现。有人知道我该如何解决这个问题吗?
这是表单的 PHP:
<?php
if(isset($_POST['submit'])) {
$name = $_POST['name'];
$address = $_POST['address'];
$number = $_POST['number'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = 'Message from Reef Cleaning solutions website';
$to = 'info@address.co.uk';
if (empty($name) || empty($address) || empty($number) || empty($email) || empty($subject) || empty($message)) {
if (empty($name))
$error['name'] = "Please enter your Full Name";
if (empty($address))
$error['address'] = "Please enter your address";
if (empty($number))
$error['number'] = "Please enter a contact number";
if (empty($email))
$error['email'] = "Please enter a valid Email Address";
if (empty($message))
$error['message'] = "Please write a message, enquiries or other concerns above";
}
else { //if not empty
$body = "
Name: $name\r\n
Address: $address\r\n
Number: $number\r\n
Email: $email\r\n
Message: $message
";
$headers="From: {$email}\r\nReply-To: {$email}"; //create headers for email
if(mail($to,$subject,$body,$headers))
{
$success = "mail has been sent";
}
else
{
echo "error during sending mail";
}
}
}
?>
这是 HTML
<form method="POST">
<table border="1">
<tr>
<td><label for="name" class="g">Name</label></td>
<td><input id="name" name="name" type="text" autofocus required /></td>
</tr>
<tr>
<td><label for="address" class="g">Address</label></td>
<td><textarea rows="3" id="address" name="address" cols="50"></textarea></td>
</tr>
<tr>
<td><label for="number" class="g">Contact number</label></td>
<td><input id="number" name="number" type="text" autofocus required /></td>
</tr>
<tr>
<td><label for="email" class="g">Email</label></td>
<td><input id="email" name="email" type="text" placeholder="example@domain.com" autofocus required /></td>
</tr>
<tr>
<td><label for="message" class="g">Enquiry</label></td>
<td><textarea rows="3" id="message" name="message" required cols="50"></textarea></td>
</tr>
</table>
<input type="submit" value="Submit" name="submit" />
<div id="message-sent">
<?php
if ($success) {
echo $success;
}
?>
</div>
</form>