dtest84004 2014-01-24 17:34
浏览 25

在DreamHost上欺骗mail.php

I'm very new to php and am having trouble with my send-mail.php file which is being hosted on 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 

Email: $email 

Message: $message";

    $headers = 'From: ' . $name . ' <' . $email . '> ' . "
" . 'Reply-To: ' . $email;

    mail( $to, $subject, $body, $headers );

    echo 'success';

}
else
{
    echo 'error';
}
// end no error send mail
?>

So this won't work on DreamHost because of their anti-spam filters.

They said this

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.  

I'm totally new to php and every time I try to edit the code, with reference to the DreamHost wiki, I end up breaking the thing!

I would really appreciate it if someone could help me out.

  • 写回答

2条回答 默认 最新

  • du31992 2014-01-24 17:37
    关注

    The FROM address needs to belong to the domain

    that's pretty much what it is about. If they did their job right, there is no way to circumvent this.

    You can set the Reply-to header if you want any responses to be sent to someone else.

    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数