knack/zerobounce

Knack Zerobounce API wrapper

Installs: 14 927

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 0

Open Issues: 2

Type:package

1.0.4 2020-12-22 03:00 UTC

README

Knack Technologies, Inc.

Knack ZeroBounce PHP API Wrapper

68747470733a2f2f636f6465636f762e696f2f67682f4b6e61636b546563682f7a65726f626f756e63652f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d56534258454b55446b54

Installing Knack's ZeroBounce

The recommended way to install Knack's ZeroBounce is through Composer. PHP 7.2+ Required.

composer require knack/zerobounce

Example usage

Laravel
<?php

use Knack\ZeroBounce\API\ZeroBounce;
use Knack\ZeroBounce\Enums\StatusEnum;

class EmailService {
    /**
     * @var ZeroBounce
     */
    private $zeroBounce;

    /**
     * EmailService constructor.
     *
     * @param ZeroBounce $zeroBounce
     */
    public function __construct(ZeroBounce $zeroBounce) {
        $this->zeroBounce = $zeroBounce;
    }

    /**
     * Validates an email address from blacklists and verifies that that domain is real.
     *
     * @param string $emailAddress
     * @param string $ipAddress
     *
     * @return bool
     */
    public function isValid(string $emailAddress, string $ipAddress = ''): bool
    {
        $response = $this->zeroBounce->validate($emailAddress, $ipAddress);

        if($response->status === StatusEnum::VALID) {
            return true;
        }

        return false;
    }
}
Vanilla PHP
<?php

use Knack\ZeroBounce\API\ZeroBounce;
use Knack\ZeroBounce\Enums\StatusEnum;

class EmailService {
    /**
     * @var ZeroBounce
     */
    private $zeroBounce;

    /**
     * EmailService constructor.
     */
    public function __construct() {
        $this->zeroBounce = new ZeroBounce(getenv('ZEROBOUNCE_API_KEY'));
    }

    /**
     * Validates an email address from blacklists and verifies that that domain is real.
     *
     * @param string $emailAddress
     * @param string $ipAddress
     *
     * @return bool
     */
    public function isValid(string $emailAddress, string $ipAddress = ''): bool
    {
        $response = $this->zeroBounce->validate($emailAddress, $ipAddress);

        if($response->status === StatusEnum::VALID) {
            return true;
        }

        return false;
    }
}

Documentation

Contributing

Submitting PRs

To submit a Pull Request to this repo, just simply open up the Pull Request targeting develop.

Please ensure all tests are passing prior to submitting your Pull Request.

Running the tests

composer test

Any of the following email addresses can be used for testing the API, no credits are charged for these test email addresses:

You can this IP to test the GEO Location in the API.

  • 99.110.204.1