Thursday, March 6, 2014

How To Send Email To Multiple Recipients With Attachments Using Codeigniter ?

Sending email is very simple in Codeigniter. The following piece of code will email with attachments to all recipients at once. It will prevent showing all recipients address in email, and will email it separately for each recipient.
//loading necessary helper classes

//setting path to attach files 
$path = set_realpath('assets/your_folder/');
$file_names = directory_map($path);

foreach ($list as $name => $address)
    //if you set the parameter to TRUE any attachments will be cleared as well  
    $this->email->subject('Here is your info '.$name);
    $this->email->message('Hi '.$name.' Here is the info you requested.'); 
    foreach($file_names as $file_name)


Here $list contains array of Recipient name and email ID. Make sure to use clear(TRUE) at the beginning of each iteration.
Example used above is taken from

No comments:

Post a Comment