php中的邮件函数未通过发送
我的Php代码最初是通过电子邮件发送的,使用的是这个确切的函数,但是现在我试图更改标题,因此电子邮件没有以@backend1.freehosting.com的形式发送,该函数无法工作 我的代码是:php中的邮件函数未通过发送,php,forms,Php,Forms,我的Php代码最初是通过电子邮件发送的,使用的是这个确切的函数,但是现在我试图更改标题,因此电子邮件没有以@backend1.freehosting.com的形式发送,该函数无法工作 我的代码是: <?php // display form if user has not clicked submit if (!isset($_POST["submit"])) { ?> <form method="post" action="<?php echo
<?php
// display form if user has not clicked submit
if (!isset($_POST["submit"])) {
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
From: <input type="text" name="from"><br>
Email: <input type="text" name="email"><br>
Subject: <input type="text" name="subject"><br>
Message: <textarea rows="10" cols="40" name="message"></textarea><br>
<input type="submit" name="submit" value="Submit Feedback">
</form>
<?php
}else {
// the user has submitted the form
// Check if the "from" input field is filled out
if (isset($_POST["from"])) {
$from = $_POST["from"]; // sender
$subject = $_POST["subject"];
$message = $_POST["message"];
// message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// send mail
$headers = 'From: me@mysitedomain.com' . "\r\n" .
'Reply-To: me@mysitedomain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail("example@hotmail.com",$subject,$message,$headers);
echo "Thank you for sending us feedback";
}
}
?>
通常,包含错误的邮件日志会发送到系统邮件服务器日志目录。如果您使用的是CentOS/RHEL/Redhat或Fedora Linux,请使用以下任一命令检查
/var/log/maillog
文件:
注意:需要在服务器上具有ssh访问权限
tail -f /var/log/maillog
grep 'user@example.com' /var/log/maillog
more /var/log/maillog
如果您正在使用Ubuntu或Debian Linux,请检查/var/log/mail.err
和/var/log/mail.log
文件:
tail -f /var/log/mail.log
tail -f /var/log/mail.err
在您需要在您的服务器上运行邮件服务器之前,这可能已经被无数次地回答过了,如果您这样做,它仍然可以被视为垃圾邮件。可能是垃圾邮件问题。你有证据证明它正在离开你的服务器吗?我总是使用swiftmailer来执行电子邮件操作,每次都很有效。我如何找到它是否离开我的服务器,因为它是一个使用免费主机的免费开发环境,所以我不熟悉它。还有-它不会进入我的垃圾邮件箱,你收到任何错误吗?没有,只是没有任何电子邮件