我是php的新手,我的send-mail.php文件遇到了问题,该文件正在dreamhost上托管。
// site owner
$to = trim( $_POST['to'] );
$subject = trim( $_POST['subject'] );
// contact form fields
$name = trim( $_POST['name'] );
$email = trim( $_POST['email'] );
$message = trim( $_POST['message'] );
// check for error
$error = false;
if ( $name === "" )
{
$error = true;
}
elseif ( $email === "" )
{
$error = true;
}
elseif ( $message === "" )
{
$error = true;
}
// end check for error
// no error send mail
if ( !$error )
{
$body = "Name: $name \n\nEmail: $email \n\nMessage: $message";
$headers = 'From: ' . $name . ' <' . $email . '> ' . "\r\n" . 'Reply-To: ' . $email;
mail( $to, $subject, $body, $headers );
echo 'success';
}
else
{
echo 'error';
}
// end no error send mail
?>
因为它们的反垃圾邮件过滤器,所以这对DreamHost不起作用。
他们说这个
The FROM address needs to belong to the domain (ie @mydomain.ie)
Once that is changed in the form settings, mail should be able to send correctly. This change was done to help prevent spam that was coming from the server:
http://dhurl.org/20b
If you would still like to keep the user inputted e-mail address, you would need to set it to be the REPLY-TO address instead of the FROM address.
我是php的新手,每当我尝试编辑代码时,参考DreamHost wiki,我最终破坏了这个东西!
如果有人可以帮助我,我真的很感激。
答案 0 :(得分:1)
由于主持人制造了限制。
只需使用您域中的电子邮件(例如noreply@yourdomain.com)查看电子邮件字段,然后按预期使用回复:
$name . ' <noreply@yourdomain.com> ' . "\r\n" . 'Reply-To: ' . $email
现在应该发送您的电子邮件。
答案 1 :(得分:0)
FROM地址需要属于域
这几乎就是它的意义所在。如果他们的工作正确,就没有办法规避这一点。
如果您希望将任何回复发送给其他人,可以设置Reply-to
标题。