Outgoing mail from PHP script being rejected


#1

I am getting this error message when I attempt to send email via PHP run periodically via a cronjob:

Diagnostic-Code: smtp; 554 5.7.1 xxx@mydreamhostdomain.com: Recipient address rejected: Access denied

It also seems to be occurring when I set the MAILTO in the crontab file to my email address.

I am usnig the following code to send email:

    $to      = 'xxx@xxx.com';
    $subject = "xxxx";
    $message = "xxxx"
    $headers = 'From: MR Alert <xxx@mydreamhostdomain.com>' . "\r\n" .
                       'MIME-Version: 1.0' . "\r\n" .
                       'Content-type: text/html; charset=iso-8859-1' . "\r\$
               'X-Mailer: PHP/' . phpversion();

    if (mail($to, $subject, $message, $headers)) {
            print "Mail sent";
    } else {
            print "Error";
    }

Can anyone tell me what’s going on? I suspect it might be Dreamhost’s spam filters, but all I’m doing is sending email to myself. Thanks.


#2

Try this for your headers:


$headers = "From: MR Alert <xxx@mydreamhostdomain.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Mailer: PHP/" . phpversion()"\r\n";

And so on.