我在我的网站上有一个php联系表格。它发送我的电子邮件在我的正常地址。但是当我在'to'部分输入所需的邮件收件人地址时。我没有收到任何电子邮件。可能是什么问题??联系表格不发送电子邮件到我的具体地址
<?php
\t if (isset($_POST["submit"])) {
\t \t $name = $_POST['name'];
\t \t $number = $_POST['number'];
\t \t $email = $_POST['email'];
\t \t $message = $_POST['message'];
\t \t $from = ' Contact Form';
\t \t $to = '';
\t \t $subject = 'Message from Website contact page ';
\t \t
\t \t $body ="From: $name\n Number: $number\n E-Mail: $email\n Message:\n $message";
\t \t // Check if name has been entered
\t \t if (!$_POST['name']) {
\t \t \t $errName = 'Please enter your name';
\t \t }
\t \t
\t \t if (!$_POST['number']) {
\t \t \t $errNumber = 'Please enter your mobile number';
\t \t }
\t \t
\t \t // Check if email has been entered and is valid
\t \t if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
\t \t \t $errEmail = 'Please enter a valid email address';
\t \t }
\t \t
\t \t //Check if message has been entered
\t \t if (!$_POST['message']) {
\t \t \t $errMessage = 'Please enter your message';
\t \t }
\t \t
// If there are no errors, send the email
if (!$errName && !$errNumber && !$errEmail && !$errMessage) {
\t if (mail ($to, $subject, $body, $from)) {
\t \t $result='<div class="alert alert-success">Thank You! We will get in touch with you soon.</div>';
\t } else {
\t \t $result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later.</div>';
\t }
}
\t }
?>
所以你没有得到邮件所需的邮件收件箱?您是否在新邮件帐户的收件箱/垃圾邮件中检查过它 – Sinto
是的,我检查过。一无所获。 –