This site uses cookies from Google to deliver its services, to personalize ads and to analyze traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. Learn More

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

How to Send Email to Multiple Recipients With Attachments Using Codeigniter ? Codeigniter,email,multiple recipents 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 $this->load->library('email'); $this->load->helper('path'); $this->load->helper('directory'); //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->clear(TRUE); $this->email->to($address); $this->email->from('your@example.com'); $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) { $this->email->attach($path.$file_name); } $this->email->send(); } 

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 http://ellislab.com/codeigniter/user-guide/libraries/email.html.

0 Response to "How to Send Email to Multiple Recipients With Attachments Using Codeigniter ?"

Posting Komentar

Contact

Nama

Email *

Pesan *