I can see that this question has been answered a number of times (eg Php Mail BCC not working) and I take on board the comments in previous responses. However the syntax I have been using is different from all the examples I have seen and want to understand firstly how to make my syntax work and secondly what the difference is.
Using the code below the mail is sent to the address in To but not to the Bcc. Can anyone explain why this might be, and also the => syntax.
$to = "to@email.com";
$from = "from@email.com";
$bcc = "bcc@email.com";
$subject = "subject";
$headers = array(
'From' => $from,
'To' => $to,
'Bcc' => $bcc,
'Subject' => $subject,
'MIME-Version' => "1.0",
'Content-type' => "text/html; charset=iso-8859-1\r\n\r\n"
);
$smtp = Mail::factory('smtp', array('host' => 'mail.host.co.uk',
'port' => '25',
'auth' => true,
'username' => 'noreply@host.co.uk',
'password' => 'password'
));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail))
{
echo('<p>' . $mail->getMessage() . '</p>');
}
else
{
echo "Sent";
}