Simple PHP script running on BlueHost where mail is handled by Google Apps:
<?php
require_once('Mail.php');
$subject = 'Test Subject';
$message = 'Test Message';
$to = '[email protected]'; // address on this domain
$from = '[email protected]'; // another address on the domain
$fromname = 'John Doe';
$headers = array(
'Return-Path' => $from,
'From' => $from,
'X-Priority' => '3',
'X-Mailer' => 'PHP ' . phpversion(),
'Reply-To' => "$fromname <$from>",
'MIME-Version' => '1.0',
'Content-Transfer-Encoding' => '8bit',
'Content-Type' => 'text/plain; charset=UTF-8',
'To' => $to,
'Subject' => $subject
);
$params = '-i -v -f ' . $from;
$sendmail = Mail::factory('sendmail', $params);
$mail = $sendmail->send($to, $headers, $message);
if (PEAR::isError($mail)) { $status = $mail->getMessage(); }
?>
$status
is being set to sendmail returned error code 8
.
Looks like I needed to do two things:
BlueHost checks that the
From:
address is in cPanel--even if Google Apps handles the mail. Apparently cPanel updates the trusted users list forsendmail
.If the
To:
address is on the same host, it also has to exist in cPanel, although I'm not sure why (sendmail
optimization?).