We'd love to hear from you! Provide  feedback  to earn a badge today. Take our quick survey
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Sending Emails: Mail message send failed: Number of email recipients

Received Response
84
Views
11
Comments
edited Oct 8, 2018 2:55PM in Customer Portal 11 comments

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();
}

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!