Great question — answering as the UphillTech team:
Twilio developer evangelist here. You need to catch the exception that is thrown from the request to send a message to the blacklisted number. You can do so with try and catch like this: foreach ($people as $number => $name) { try { $sms = $client->account->messages->create( $number, array( 'from' => "+18443949780", 'body' => "Hey $name, this is Hussam. Testing Twilio SMS API!" ) ); echo "Sent message to $name.\n"; } catch (\Twilio\Exceptions\RestException $e) { echo "Couldn't send message to $number\n"; } } When you hook this up to a database, you'll want to use the catch to update a field to mark the number as blocked so that you don't try to send to it again. Let me know if that helps at...
Full answer by philnash: https://stackoverflow.stackexchange.com/a/40998443 (CC BY-SA 3.0).
Need it done for your business? UphillTech.