S
S
sllugovskih2016-09-19 21:44:02
CodeIgniter
sllugovskih, 2016-09-19 21:44:02

Codeigniter sending multiple messages doesn't work, why?

It was necessary to implement the function of sending messages to all registered users in the CodeIgniter project. Sending via SMTP works without problems for notifications for 1-2-3 mailboxes. But if you need to send out mailings to 50+ addresses, then errors appear.
1) Message: fwrite(): SSL: Broken pipe
2) Periodically Gateway Time-out
Code piece:

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.mail.ru';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'username';
$config['smtp_pass'] = '123456789';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
$config['mailtype'] = 'html';
$config['bcc_batch_mode'] = true;
$config['bcc_batch_size'] = 200;
$config['validate'] = true;

//в массиве $results - храняться 50+ email адресов
//в цикле отправляем письмо на каждый ящик
foreach ($results as $key => $result) {
  $this->email->clear();
  $this->email->initialize($config);
  $this->email->from('[email protected]', 'MYNAME');
  $this->email->to($result);
  $this->email->subject('Тема письма');
  $this->email->message('А тут сообщение');	

  $this->email->send();
}

I use mail on the Mail.ru domain SPF record is configured

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DuD, 2016-09-28
@DuD

At its simplest, try adding a pause between redirects. Maybe they just cut you down the stream.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question