You are here

public static function SendinblueManager::validationEmail in SendinBlue 7

Same name and namespace in other branches
  1. 7.2 includes/sendinblue.manage.inc \SendinblueManager::validationEmail()

Check the email address of subscriber.

Parameters

string $email: An email address.

string $list_id: A list id.

Return value

array A response information.

1 call to SendinblueManager::validationEmail()
sendinblue_signup_subscribe_form_validate in ./sendinblue.module
Validate handler to add users to lists on subscription form submission.

File

includes/sendinblue.manage.inc, line 473
Manage class file.

Class

SendinblueManager
Basic manager of module.

Code

public static function validationEmail($email, $list_id) {
  $access_key = variable_get(self::ACCESS_KEY, '');
  $mailin = new SendinblueMailin(self::API_URL, $access_key);
  $response = $mailin
    ->getUser($email);
  if ($response['code'] == 'failure') {
    $ret = array(
      'code' => 'success',
      'listid' => array(),
    );
    return $ret;
  }
  $listid = $response['data']['listid'];
  if (!is_array($listid)) {
    $listid = array();
  }
  if ($response['data']['blacklisted'] == 1) {
    $ret = array(
      'code' => 'update',
      'listid' => $listid,
    );
  }
  else {
    if (!in_array($list_id, $listid)) {
      $ret = array(
        'code' => 'success',
        'listid' => $listid,
      );
    }
    else {
      $ret = array(
        'code' => 'already_exist',
        'listid' => $listid,
      );
    }
  }
  return $ret;
}