$email = explode(",", $params['headers']['Bcc'] );
$connection = \Drupal::database();
$u_name = '';
$u_id = '';
$u_roles = '';
foreach ($email as $key => $value) {
$query = $connection->select('users_field_data', 'u');
$query->join('user__roles', 'roles', 'roles.entity_id = u.uid');
$query->condition('u.mail', $value, '=');
$query->fields('u', array('uid','name'));
$query->fields('roles', array('roles_target_id'));
$result= $query->execute()->fetch();
$u_name .= $result->name . ',';
$u_id .= $result->uid . ',';
$u_roles .= $result->roles_target_id . ',';
}
$u_name_new = rtrim($u_name, ',');
$u_id_new = rtrim($u_id, ',');
$u_roles_new = rtrim($u_roles, ',');