brettbrewer.com

Programming + Design

Home
Specifying Multiple recipients for Kohana's email helper library PDF Print E-mail
Written by Brett Brewer   
Tuesday, 27 October 2009

I love the Kohana framework, but some of their docs are pretty bad. I've used it for months without knowing how to specify multiple recipients for the email::send() helper function which uses the SwiftMailer library. Today I looked at the source code and figured out how to specify multiple recipient addresses. Here's how:

$to = array(
     'to'=>array('address@somewhere.com','Recipient Name'),
     'to1'=>array('address1@somewhere.com','Recipient1 Name'),
     'to2'=>array('address2@somewhere.com','Recipient2 Name'),
     'cc'=>array('ccaddress@somewhere.com','cc Recipient Name'),
     'bcc'=>array('bccaddress@somewhere.com','bcc Recipient Name')
);

$sentcount = email::send($to,$from,$subject,$body,true);

This assumes you've already set some vars for the $from address, message $subject, $body, etc. The trick to this is that Kohana's email::send() funtion will loop through your "to" array and anything that doesn't match the 'to','cc' or 'bcc' array keys will be sent as an additional "to" recipient. Even if you call the other keys "cc1","cc2", etc., the messages will be sent to them as primary recipients and their email address will show in the "to" field. There is no Kohana documentation anywhere to tell you this, so I hope this helps someone. 

Last Updated ( Tuesday, 27 October 2009 )
 
< Prev

Search

Who's Online

We have 1 guest online

© 2017 www.brettbrewer.com
Joomla! is Free Software released under the GNU/GPL License.