You are here

public static function SendinblueManager::validationEmail in SendinBlue 7.2

Same name and namespace in other branches
  1. 7 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 377
Manage class file.

Class

SendinblueManager
Basic manager of module.

Code

public static function validationEmail($email, $list_id) {
  $sendinblueMailin = new SendinblueMailin();
  $contactInfo = $sendinblueMailin
    ->getUser($email);
  if ($contactInfo === NULL) {
    $ret = [
      'code' => 'success',
      'listid' => [],
    ];
    return $ret;
  }
  $listId = $contactInfo
    ->getListIds();
  if ($contactInfo
    ->isEmailBlacklisted()) {
    $ret = [
      'code' => 'update',
      'listid' => $listId,
    ];
  }
  else {
    if (!in_array($list_id, $listId, true)) {
      $ret = [
        'code' => 'success',
        'listid' => $listId,
      ];
    }
    else {
      $ret = [
        'code' => 'already_exist',
        'listid' => $listId,
      ];
    }
  }
  return $ret;
}