Problems sending mail with php in contact script?


#1

Hello,

I have a contact page on my website… Everytime I test it it doesn’t get delivered and I end up with:

said: 550 5.7.1 Sender domain not allowed. Please read: http://dhurl.org/20b D21 (in reply to end of DATA command)

listed in my log file. I’ve read the wiki link but I still am at a loss as to what’s wrong. I’m using an e-mail in that domain hosted by dreamhost. This is my send script:

[code]<?php
// Check for empty fields
if(empty($_POST[‘name’]) ||
empty($_POST[‘email’]) ||
empty($_POST[‘phone’]) ||
empty($_POST[‘message’]) ||
!filter_var($_POST[‘email’],FILTER_VALIDATE_EMAIL))
{
echo “No arguments Provided!”;
return false;
}

$name = $_POST[‘name’];
$email_address = $_POST[‘email’];
$phone = $_POST[‘phone’];
$message = $_POST[‘message’];

// Create the email and send the message
$to = ‘chris@cjs-design.com’;
$email_subject = “Website Contact Form: $name”;
$email_body = “You have received a new message from your website contact form.\n\n”.“Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message”;
$headers = “From: chris@cjs-design.com”;
$headers .= “Reply-To: $email_address”;
mail($to,$email_subject,$email_body,$headers);
return true;
?>[/code]

What am I doing wrong?

Thanks in advance,

Chris


#2

Does $_POST[‘email’] contain a gmail address? If so, you’ll get that message.


#3

No, it contains my e-mail for my website. Same domain. chris@cjs-design.com and it’s cjs-design.com where the form is…
[hr]

Ok, nevermind, I see where you are going with this. Yes I was trying to test with a gmail account. Why does that happen just to gmail addresses? -.-


#4

Did you read the link? http://wiki.dreamhost.com/Sender_Domain_Policy_and_Spoofing#What_is_the_sender_domain_policy.3F

One way to get around it is to use SMTP to send the message.