Problems sending mail with php in contact script?


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: 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:

// Check for empty fields
if(empty($_POST[‘name’]) ||
empty($_POST[‘email’]) ||
empty($_POST[‘phone’]) ||
empty($_POST[‘message’]) ||
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 = ‘’;
$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:”;
$headers .= “Reply-To: $email_address”;
return true;

What am I doing wrong?

Thanks in advance,


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

No, it contains my e-mail for my website. Same domain. and it’s where the form is…

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? -.-

Did you read the link?

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