[英]spoofing mail.php on DreamHost
我是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,我最終還是搞砸了!
如果有人可以幫助我,我將不勝感激。
由於主機創建限制。
只需在您的電子郵件字段中使用來自您的域的電子郵件(例如,noreply @ yourdomain.com),然后按預期使用“回復”即可:
$name . ' <noreply@yourdomain.com> ' . "\r\n" . 'Reply-To: ' . $email
您的電子郵件現在應該已發送。
FROM地址必須屬於該域
差不多就是這個了。 如果他們做得對,就沒有辦法避免這種情況。
如果您希望將任何響應發送給其他人,則可以設置Reply-to
標頭。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.