name = 'Singletest'; $this->data = []; } public function defaultTask() { $this->layout = 'default'; $this->breadcrumb[__('Single test', 'acychecker')] = Url::completeLink('singletest'); $this->display(); } public function ajaxGetSingleTest() { $apiService = new ApiService(); $conditions = 'disposable,accept_all,domain_not_exists,free_domain,invalid_smtp,not_existing,role_based,accept_all'; $email = Security::getVar('string', 'email', ''); if (!empty($email)) { $user = new \stdClass(); $user->email = $email; $result = $apiService->testUser($user, $conditions, true); } else { $result = []; } if (!is_array($result) || empty($result)) { Ajax::sendAjaxResponse(__('Could not call the api', 'acychecker'), [], false); return; } $isValid = $result['exists']; $colorMap = [ self::STATUS_SUCCESS => 'green', self::STATUS_INVALID => 'red', self::STATUS_INFO => 'blue', self::STATUS_NOT_TESTED => 'gray', ]; $tests = [ 'valid' => [ 'status' => $result['valid'] ? self::STATUS_SUCCESS : self::STATUS_INVALID, 'label' => $result['valid'] ? __('Valid email syntax', 'acychecker') : __('Invalid email syntax', 'acychecker'), 'description' => $result['valid'] ? __('The syntax of the email address is correct', 'acychecker') : __('The syntax of the email address is incorrect', 'acychecker'), ], self::API_TEST_KEY_DOMAIN_EXISTS => [ 'status' => $result[self::API_TEST_KEY_DOMAIN_EXISTS] ? self::STATUS_SUCCESS : self::STATUS_INVALID, 'label' => $result[self::API_TEST_KEY_DOMAIN_EXISTS] ? __('Domain exists', 'acychecker') : __('The domain doesn\'t exist', 'acychecker'), 'description' => $result[self::API_TEST_KEY_DOMAIN_EXISTS] ? __('The domain of the email address exists. It does not necessarily imply that the email address is valid.', 'acychecker') : __('This means that the domain doesn\'t exist and therefore the email address doesn\'t exist either. It is highly discouraged to send emails to addresses that don\'t exist as it impacts your IP reputation and mail clients may ultimately consider you as a spammer.', 'acychecker'), ], 'exists' => [ 'status' => in_array($result['exists'], [self::TRUST_RESULT_RISKY, self::TRUST_RESULT_POSSIBLE]) ? self::STATUS_SUCCESS : self::STATUS_INVALID, 'label' => in_array($result['exists'], [self::TRUST_RESULT_RISKY, self::TRUST_RESULT_POSSIBLE]) ? __('The email address exists', 'acychecker') : __('The email address doesn\'t exist', 'acychecker'), 'description' => in_array($result['exists'], [self::TRUST_RESULT_RISKY, self::TRUST_RESULT_POSSIBLE]) ? __('We asked via SMTP protocol if we can send an email to this email address and the server confirmed that the email address exists.', 'acychecker') : __('This means that the email address doesn\'t exist. We couldn\'t contact the SMTP server of the domain, the domain doesn\'t exist or the domain told us that the email address doesn\'t exist.', 'acychecker'), ], 'disposable' => [ 'status' => !$result[self::API_TEST_KEY_DOMAIN_EXISTS] ? self::STATUS_NOT_TESTED : self::STATUS_INFO, 'label' => !$result[self::API_TEST_KEY_DOMAIN_EXISTS] ? __('Disposable', 'acychecker') : ($result['disposable'] ? __('Is disposable', 'acychecker') : __('Disposable', 'acychecker')), 'description' => __('A disposable email address is temporary. It\'s convenient for people who don\'t want to give their real email address on a website. For your email marketing it isn\'t great as you send emails to non-existing users.', 'acychecker'), ], 'free' => [ 'status' => !$result[self::API_TEST_KEY_DOMAIN_EXISTS] ? self::STATUS_NOT_TESTED : self::STATUS_INFO, 'label' => !$result[self::API_TEST_KEY_DOMAIN_EXISTS] ? __('Free email address', 'acychecker') : ($result['free'] ? __('Is a free email address', 'acychecker') : __('Free email address', 'acychecker')), 'description' => __('This means that the email address has been created on a free service like Gmail or Yahoo for example. There are no cons on your side if you want to send marketing emails to them.', 'acychecker'), ], 'role' => [ 'status' => !$result[self::API_TEST_KEY_DOMAIN_EXISTS] ? self::STATUS_NOT_TESTED : self::STATUS_INFO, 'label' => !$result[self::API_TEST_KEY_DOMAIN_EXISTS] ? __('Role based email address', 'acychecker') : ($result['role'] ? __('Is a role based email address', 'acychecker') : __('Role based email address', 'acychecker')), 'description' => __('Role-based email addresses are addresses that do not belong to a specific user but more to a role, for example support@example.com is a role-based email address.', 'acychecker'), ], 'accept_all' => [ 'status' => !$result[self::API_TEST_KEY_DOMAIN_EXISTS] ? self::STATUS_NOT_TESTED : self::STATUS_INFO, 'label' => !$result[self::API_TEST_KEY_DOMAIN_EXISTS] ? __('Accept all email address', 'acychecker') : ($result['accept_all'] ? __('Is an accept all email address', 'acychecker') : __('Accept all email address', 'acychecker')), 'description' => __('Accept all email addresses mean that all addresses on that domain will work. You\'ll be able to send emails to them but there are potentially no one receiving them.', 'acychecker'), ], ]; $this->data['result'] = $result; $this->data['tests'] = $tests; $this->data['colorMap'] = $colorMap; $this->data['isValid'] = $isValid; ob_start(); include ViewService::getView('Singletest', 'default_results'); $resultsHtml = ob_get_clean(); ob_start(); include ViewService::getView('Singletest', 'default_details'); $detailsHtml = ob_get_clean(); Ajax::sendAjaxResponse('', [ 'results' => $result, 'html' => [ 'results' => $resultsHtml, 'details' => $detailsHtml, ], ]); } }