PHP mail() through Dreamhost



My company uses dreamhost for several websites and we also use dreamhost to host our email for

We actually host the webserver at our office and everything works great except when I’m trying to send auto emails.

Using php and the basic mail(), I’ve modified the .ini settings to have:
smtp_port: 587

When trying to send the email I get the following error:

mail() [function.mail]: SMTP server response: 554 5.7.1 <unknown[]>: Client host rejected: Access denied

I’m assuming because the email is originating form my server ( and the dreamhost email server is rejecting?

The test php code is as follows:

$to = ‘’;
$subject = ‘Test from ryan’;
$message = ‘test’;
$headers = ‘From:’ . “\r\n” .
‘Reply-To:’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();

mail($to, $subject, $message, $headers);

Thanks for your help!


I ran a couple tests and sorted this much out:


$to = "";

$headers = "From:\r\n";
$headers .= "Reply-To:\r\n";
$headers .= "X-Mailer: PHP/" . phpversion()"\r\n";

$subject = "Test from Ryan";
$message = "This is a test.";

mail($to, $subject, $message, $headers);

That seems to work for me, though I’m using gmail as my email here. Is the email.php (or whatever) file on your DH server or on your own webhost? I’m assuming webhost.


The webserver is hosted in our office. So the A record in our DNS file on dreamhost points here. But we are using Dreamhost for the mail for the URL.

So the email is originating here at my office and I’ve setup our PHP server to use dreamhost for the smtp. Which is not working, but I’m hoping it will.

My guess is that I need to use a more advanced mail feature (Pear: Mail?) which allows me to plug in authentication info during the send?


Ah, yeah, you’d need to authenticate, thanks to those darn spammers. should do it.


Awesome, that worked. Thanks buddy!