Php mail

software development


This code works fine on other web hosts. Someone please let me know what I need to change to make it work with Dreamhost.

(Regarding my account, the account I am currently using only has an Affiliate account, but I manage a number of websites hosted on Dreamhost for clients - clients I actually referred to Dreamhost)

Here is my code. I know there are ways to make this safer but, most importantly, I need it work. Thanks.

$name = $_POST[‘name’];
$email = $_POST[‘email’];
$phone = $_POST[‘phone’];
$message = $_POST[‘message’];
$subject = $_POST[‘subject’];
$formcontent=“Sent from\n\nName: $name\nE-mail: $email\nPhone: $phone\n\nMessage:\n$message”;
$recipient = "";
$subject_full = “ $subject”;
$mailheader = “From: $email \r\n”;
mail($recipient, $subject_full, $formcontent, $mailheader) or die(“Error!”);
echo “<meta http-equiv=“refresh” content=“0;url=…/ThankYou.html”>”;


Set the “From:” header to a single email address associated with the site that’s sending the message, not the user’s email address. If you need to have replies go to the email address the user entered, use the “Reply-To:” header for that.


I had similar mail functions working find and now it seems that I’m also no longer getting mail through. I even put a small test script:

<?php $to = ""; $subject = "Test mail"; $message = "Hello! This is a simple email message."; $from = ""; $headers = "From:" . $from; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?>

And I get nothing now.


Is the email your domain that you’re sending from?

$from = "";


I was just told that DH no longer allows any relaying from unauthenticated email addresses. My domain ( and its email address that I set to the $from is hosted by google. With that being said, is there anyway I can get my webforms to send out successfully from any email address?

If I have to go through authentication, should I be able to use the information here with my oldsmobilecentral / gmail credentials?


Yes, that indeed would be what’s going on :frowning: If your domain was hosted here, and just the email was with gmail, it would work.

I believe you can do that with phpMailer:


I was really hoping for a quick basic way, but when I get time I’ll go ahead and try to implement everything with phpMailer. Hopefully things run smoothly.


I was able to use phpmailer with my gmail account without any issues. Thanks


Good to know! Whew. :smiley: