Bulk mailing in codeigniter

78 Views Asked by At

I want to send promotional emails to all my clients. i have txt file with all email lists.

bellow is my code to send email but this code is working sometimes only and sometimes its not working.

Sample for text file:

[email protected]
[email protected]
[email protected]

and so on.

This file is stored in root directory.

now my controller's code.

$file = fopen("10.txt", "r");
$str = "";
$i = 0;
while (!feof($file)) {
  if($i != 0){ $str .= ","; }else{ $i++;}
  $str .= fgets($file);
}
fclose($file);
$this->load->library('email');
$this->email->clear(TRUE);
$this->email->from('[email protected]', 'Name Here');
$this->email->to('[email protected]'); 
$this->email->bcc($str); 
$this->email->set_mailtype("html");
$this->email->subject('Subject here');
$message = $this->load->view('email-template', '' , true);  
$this->email->message($message);    
$this->email->send();

Can you please help me to solve this issue?

0

There are 0 best solutions below