0

Codeigniter "bcc" doesn't work, But the same code with "to" works just fine! Any suggestions why this happens and how to fix it?

Here's my code:

        $email = "myEmail@myWebsite.com";

        $subject = "my subject";
        $message = "my message";

        $this->email->set_mailtype("html"); // In my actual code this is needed

        $this->email->from('myWebsiteEmail@myWebsite.com', 'Info');
        // $this->email->to($email); // It works with this code
        $this->email->bcc($email); // It doesn't work with this code

        $this->email->subject($subject);
        $this->email->message($message);

        $this->email->send();

Any suggestions would be appreciated!

Mandana Rz
  • 29
  • 11

3 Answers3

0

You have to have a to to be able to bcc

Try adding an email to the to as well as a bcc and it should work.

GrahamTheDev
  • 22,724
  • 2
  • 32
  • 64
  • Yes, It works that way! I added $this->email->to("") with an empty string and now it works just fine!!! Thanks a lot! – Mandana Rz May 27 '14 at 12:43
  • Not working. `$this->email->to("")` makes error occur if you're using Mailtrap.io. – monteirobrena Feb 19 '21 at 02:39
  • The advice is to add an email to the `to` not leave it empty, try adding a valid email address to the `to` field. Also mailtrap.io is not part of CodeIgniter so you need to check their docs to see if they allow email sending without a `to` address (which I doubt) even if CodeIgniter now allows it (as I haven't used it in 5 years so I am not up on the latest versions). – GrahamTheDev Feb 19 '21 at 07:58
0

You may need to enable bcc_batch_mode in email config. By default is value is FALSE.

Himanshu Saini
  • 702
  • 11
  • 25
-1

It doesn't need a $this->email->to() all you need to do is set $config['bcc_batch_mode'] = TRUE; and then add the emails like $CI->email->bcc( $bccEmailArray );. The bcc method does not work like the cc method.

Lu CT
  • 116
  • 3