Skip to content

// website builders and cms

Via API

PrestaShop email verification with pingutil

PrestaShop stores pick up customer accounts made with temp-mail addresses to farm first-order vouchers and newsletter discounts, and order confirmations to those addresses bounce. A small module on actionSubmitAccountBefore runs before the customer form is submitted on the registration page and in the checkout personal information step, so it can ask pingutil about the email and return false to stop the account. If pingutil is slow or unavailable, the hook returns true and the customer is created.

Where it connects: actionSubmitAccountBefore hook in a PrestaShop 8 module (registration page and checkout personal information step)

What goes wrong without it

  • New-customer vouchers keep getting used by accounts on yopmail and 10minutemail, often several per day from the same person.
  • Order confirmation and shipping emails bounce, and real customers then ask where their order is.
  • The customer list is full of accounts with random addresses that never placed an order and still get our newsletter.

What you can do with PrestaShop and pingutil

  • Stop throwaway accounts on the registration page and at checkout

    Both RegistrationController and the checkout personal information step call actionSubmitAccountBefore when submitCreate is posted. Return false when verdict.is_spam is true and the customer form is never submitted.

  • Protect first-order and sign-up vouchers

    Cart rules that reward new customers only pay out once the account exists. Blocking disposable addresses at creation removes the easiest way to claim the same voucher repeatedly.

  • Review business buyers separately

    On actionCustomerAccountAdd, which runs after the customer is saved, a full /v1/lookup returns category and company, so you can put company buyers in a B2B customer group.

Set it up

  1. 1

    Create an API key in the pingutil dashboard.

  2. 2

    Create modules/pingutilcheck/pingutilcheck.php with the module class below, and store the key with Configuration::updateValue('PINGUTIL_API_KEY', ...) from a getContent() settings form or a one-off script.

  3. 3

    Install the module from Modules → Module Manager → Upload a module; install() registers actionSubmitAccountBefore.

  4. 4

    Create an account with test@mailinator.com on the registration page and at checkout to confirm the error notification shows, then use your own address to confirm it passes.

  5. 5

    If your theme or a one-page checkout module replaces the core checkout, confirm it still calls actionSubmitAccountBefore.

modules/pingutilcheck/pingutilcheck.php
<?php

if (!defined('_PS_VERSION_')) {
    exit;
}

class PingutilCheck extends Module
{
    public function __construct()
    {
        $this->name = 'pingutilcheck';
        $this->tab = 'front_office_features';
        $this->version = '1.0.0';
        $this->author = 'Your team';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = ['min' => '8.0.0', 'max' => _PS_VERSION_];
        parent::__construct();
        $this->displayName = 'pingutil account check';
        $this->description = 'Rejects disposable and machine-generated emails at account creation. Fails open.';
    }

    public function install()
    {
        return parent::install() && $this->registerHook('actionSubmitAccountBefore');
    }

    /**
     * Runs before the customer form is submitted (registration page and checkout).
     * Core ANDs every module's return value: always return true unless blocking.
     */
    public function hookActionSubmitAccountBefore($params)
    {
        $email = trim((string) Tools::getValue('email'));
        $key = (string) Configuration::get('PINGUTIL_API_KEY');
        if ($key === '' || !Validate::isEmail($email)) {
            return true; // Let core validation handle empty or malformed input.
        }

        $ch = curl_init('https://pingutil.com/v1/lookup');
        curl_setopt_array($ch, [
            CURLOPT_POST => true,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_CONNECTTIMEOUT => 2,
            CURLOPT_TIMEOUT => 3,
            CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $key, 'Content-Type: application/json'],
            CURLOPT_POSTFIELDS => json_encode(['input' => $email, 'skip_enrichment' => true]),
        ]);
        $body = curl_exec($ch);
        $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        if ($body === false || $status !== 200) {
            return true; // Timeout, 429 quota_exceeded or 5xx: fail open.
        }

        $data = json_decode($body, true);
        if (!empty($data['verdict']['is_spam'])) {
            $this->context->controller->errors[] = $this->trans(
                'Please use a permanent email address to create your account.',
                [],
                'Modules.Pingutilcheck.Shop'
            );
            return false;
        }

        return true;
    }
}

What to do with each result

pingutil resultAction in PrestaShop
verdict.is_spam: true (disposable_domain, randomized_local_part)Add a controller error and return false; the customer form is not submitted.
verdict.low_trust: true (role_based, system_generated)Return true; optionally note the reason on the customer from actionCustomerAccountAdd.
category: "company" (from a later full lookup)Add the customer to a B2B group in actionCustomerAccountAdd.
Timeout, 429 or 5xxReturn true so the account is created as usual.

Limits to plan for

  • Core combines the return values of every module on this hook with a logical AND, so a module that returns nothing blocks registration. Return true explicitly on every path that should allow the account.
  • The hook receives no parameters; the module reads the posted email with Tools::getValue('email'). Customers created in the back office or through the webservice API do not pass through it.
  • Fast mode does not check the mailbox, so a mistyped address on a real domain can still create an account. Run /v1/verify on new customers from actionCustomerAccountAdd if order emails bounce for that reason.

PrestaShop documentation

PrestaShop is a trademark of its owner. This integration uses PrestaShop's documented extension points; it is not an official PrestaShop app.

Common questions

Why not validateCustomerFormFields?
PrestaShop only passes that hook the form fields your module added through additionalCustomerFormFields, not the core email field. actionSubmitAccountBefore runs earlier and lets the module read the posted email.
Does this cover guest checkout?
The checkout personal information step calls actionSubmitAccountBefore when the customer form is submitted there, which in core includes the guest form. If you use a third-party one-page checkout, test it, because those modules often post their own forms.

Stop bad addresses in PrestaShop today

Sign in with your email, create an API key and paste it into the step above. Test on a few real addresses first: the live demo shows exactly what your PrestaShop setup will receive.