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 = 'to@example.com'; // address on this domain
$from = 'from@example.com'; // 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
.