Search the blog

ProcessWire’s mail class does not have a function for CC and BCC so use this (where $mail is an instance of WireMail):

function pwMailCopyIn($mail, $type, $email) {
	
	$type = in_array($type, ['cc', 'bcc']) === true ? $type : 'cc';
	
	// $data can be single email (in which case $data is fine as is), numerical array of emails or associative array of email => name
	$mail->header($type, $email);
	
	return $mail;
	
}

$mail = pwMailCopyIn($mail, 'cc',  'email1@domain.com');
$mail = pwMailCopyIn($mail, 'bcc', 'email2@domain.com');
Tim Bennett is a Leeds-based web designer from Yorkshire. He has a First Class Honours degree in Computing from Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.