CodeIgniter email library bug
Today while creating a newsletter module for my personal CMS I ran into a weird CodeIgniter bug in the email library. When you are trying to send an email to a number of people while only using the BCC field you might see the following error message:
A PHP Error was encountered Severity: Warning Message: mail() expects parameter 1 to be string, array given Filename: libraries/Email.php Line Number: 1540
For some reason the email library will not convert the $to variable for the mail() function into a string and pass it as an array. One solution would be to adjust the email class to always implode the $to variable, but this means editing CodeIgniter system libraries which should be avoided at all time. But no worries, I have found a clean and simple solution how to fix this problem.
Instead of only using $this->email->bcc($emails) you need to add the following line:
This will activate the implode for the $to variable and fix the problem. I hope this helped!