For anyone who stumbles upon this after so long after it was made, the workflow makes a lot more sense when you know about smtp, take this example using putty (when you look at an email sent through like this, you get to understand it more and more):

220 ************.com ESMTP Postfix
helo ************.com
250 ************.com
mail from: /* This is who the message is  from*/
250 2.1.0 Ok
rcpt to: // This is whom the message is intended//
250 2.1.5 Ok
data  /* initialising the main data (this includes all the displayed data (subject, to address, from address, cc's etc..))*/
354 End data with .
subject: hello /*the displayed subject*/
from: nick /*the from address this completes as [email protected]([address given at the start].com)*/
/*this new line indicates the message starts and headers end*/
hello this is a test


/*. (this indicates the end of the message(not inputting the actual characters, these are Carriage returns and line feeds (confused me at first XD))) */
250 2.0.0 Ok: queued as 554561217AF

now when you look at the message:
== header ==
from:	 [email protected]************.com
reply-to:	 [email protected]************.com,

to:	         /* if you notice above, there is no to: address specified...*/
date:	 Wed, Nov 20, 2013 at 11:56 AM
subject:	 hello

== The message content ==
hello this is a test

############################################
### from here it is info about the actual mail function ###
############################################

require_once "/usr/share/pear/Mail.php"; /*default install locations on my EC2 instance*/
require_once "/usr/share/pear/Mail/mime.php";

$from = "no-reply ";
$subject = "This is a test";
$crlf = "rn";
$html = "This is a test, hi all!";
$from = "someone ";
$to   = "nick "; /*this is the address that will be displayed in the to: header*/
$totwo= "steve "; /*this is the BCc we don't want this in the headers ;) */

$headers = array('From' => $from, /*if we were in putty this would be From: [from address]*/
		'To' => $to,  /*if we were in putty this would be To: [To address]*/
		'Subject' => $subject); /*if we were in putty this would be subject: [your subject]*/

//$host = "smtp.gmail.com";
$host = "ssl://smtp.gmail.com"; // try this one to use ssl
$port = 465;
$username = "[email protected]************.com"; /* email address of google account*/
$password = "************";  /* password of that account*/

//$mime = new Mail_mime($crlf);
$mime =  new Mail_mime(array('eol' => $crlf)); /* i believe this is where we separate the header and message info[but don't take my word on it XD] this is based on the pear doc*/
$mime->setHTMLBody($html);

//$body = $mime->get();
$body = $mime->getMessageBody(); //based on pear doc above
$headers = $mime->headers($headers);

$smtp = Mail::factory("smtp",array("host" => $host,
		"port" => $port,
		"auth" => true,
		"username" => $username,
		"password" => $password));

$sendto = array($to, $totwo); /* can be either a single value or an array,  an array is the better option as then you could just use an array to input the to values ;)  */

$mail = $smtp->send($sendto, $headers, $body);

if (PEAR::isError($mail)) {
	echo $mail->getMessage();
} else {
	echo "Message sent successfully!";
}
echo "n";

I was recently taught this so may be a couple of errors in my explanation, in terms of BCc, the idea is you don’t put in header information, that why when you try and put in the headers field

Bcc => email

it wont work, I hope this helps someone 🙂

Thanks,

Steve,