简体   繁体   中英

Some contact form emails not being sent due to spam filtering on host

I need my contact form on my website to be adjusted. It's a PHP/Ajax Contact Form.

Currently i have a problem - When a client fills out my contact form NAME - EMAIL - SUBJECT - MESSAGE there is an issue with my DREAMHOST Server due to their new anti spam policy and i dont receive some messages - If their email is @hotmail.com that's fine. But if their email is @gmail.com i dont get the message etc.

DREAMHOST TELLS ME:

Thanks for contacting Tech Support I checked the logs for the form on your site and did see that the emails are being bounced by the server due to recently implemented anti spam policies which won't allow email sent from the server using non-Dreamhost outgoing servers or "send from" email addresses. You can read more details on this policy here:

http://wiki.dreamhost.com/Sender_Domain_Policy_and_Spoofing

Your mail form uses the visitor's email address as the 'From' address which in most cases is not a Dreamhost hosted email address. Due to the spam policy above, the server will block mail being sent off the server if the email addresses are not using Dreamhost mail servers. So what you will need to do is either set the mail form to use your Dreamhost hosted address as the 'From' address.

Or you will need to find another mail form that will allow you to set a fixed email address as the 'From' address. This way you can set a Dreamhost hosted email address in the form as the 'From' address.

THE CODE AS FOLLOWS:

<?php
/*
Credits: Bit Repository
URL: http://www.bitrepository.com/
*/

include dirname(dirname(__FILE__)).'/config.php';

error_reporting (E_ALL ^ E_NOTICE);

$post = (!empty($_POST)) ? true : false;

if($post)
{
include 'functions.php';

$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$subject = stripslashes($_POST['subject']);
$message = stripslashes($_POST['message']);


$error = '';

// Check name

if(!$name)
{
$error .= 'Please enter your name.<br />';
}

// Check email

if(!$email)
{
$error .= 'Please enter an e-mail address.<br />';
}

if($email && !ValidateEmail($email))
{
$error .= 'Please enter a valid e-mail address.<br />';
}

// Check message (length)

if(!$message || strlen($message) < 15)
{
$error .= "Please enter your message. It should have at least 15 characters.<br />";
}


if(!$error)
{
$mail = mail(WEBMASTER_EMAIL, $subject, $message,
     "From: ".$name." <".$email.">\r\n"
    ."Reply-To: ".$email."\r\n"
    ."X-Mailer: PHP/" . phpversion());


if($mail)
{
echo 'OK';
}

}
else
{
echo '<div class="notification_error">'.$error.'</div>';
}

}
?>

All i need to know is what i need to do to the code so i can receive all submissions of my contact form. I would really be grateful if someone could help.

Replace the following:

mail = mail(WEBMASTER_EMAIL, $subject, $message,
 "From: ".$name." <".$email.">\r\n"
."Reply-To: ".$email."\r\n"

with just:

$mail = mail(WEBMASTER_EMAIL, $subject, $message,"X-Mailer: PHP/" . phpversion());

and add the user's email address to your message if you need to. What you are doing right now is called spoofing and even when well-intentioned, you are essentially committing fraud. It would be the equivalent of someone calling you to show interest in your product and you taking down their physical address and putting that in the upper-left corner of an envelope and then sending yourself a letter saying that the caller is interested. In addition to this just being a fairly-odd way of doing things, it also suggests an electronic paper trail that suggests the user actually emailed you, which they did not. I personally would be uncomfortable finding out my email address was used in this way after filling out an online form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM