1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | //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(); } |