Sending Emails: Mail message send failed: Number of email recipients
Content
Hi,
Please see code below - on the 2nd loop, I get an error:
Fatal error: Uncaught exception 'RightNow\Connect\v1_4\ConnectAPIError' with message 'Mail message send failed: Number of email recipients 400 exceeds the remaining allowable recipients
However, it should be split to be 200 each time. The first time in the loop, the email gets sent. The second time however, it seems to concatenate it.
Any ideas?
Thanks,
JJ
Code Snippet
RNCPHP\ConnectAPI::getCurrentContext()->ApplicationContext = "Get emails"; $e = Array();; $ar= RNCPHP\AnalyticsReport::fetch(123456); $arr= $ar->run( 0, $filters ); $nrows= $arr->count(); if ( $nrows) { $row = $arr->next(); for ( $ii = 0; $ii++ < $nrows; $row = $arr->next() ) { try { $e[] = $row["Email Address"]; } catch ( \Exception $err ){ echo "<br><b>Exception</b>: line ".__LINE__.": ".$err->getMessage()."</br>"; } } } $n = array_chunk($e, 199); RNCPHP\ConnectAPI::getCurrentContext()->ApplicationContext = "Send emails"; foreach ($n as $k => $v) { $mm = new RNCPHP\MailMessage(); $mm->To->EmailAddresses = array('[email protected]'); $mm->BCC->EmailAddresses = $v; // THIS IS 200 EACH TIME $mm->Subject = 'SUBJECT'; $mm->Body->Html = 'CONTENT'; $mm->Options->IncludeOECustomHeaders = false; $mm->send(); }
1