# acymailing/trunk/front/FrontControllers/FrontservicesController.php

AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress, version trunk. 81 lines.

- Page: https://pluginprobe.com/plugins/acymailing/trunk/code/front/FrontControllers/FrontservicesController.php
- Raw: https://pluginprobe.com/plugins/acymailing/trunk/raw/front/FrontControllers/FrontservicesController.php
- Modified: 2026-08-03T10:18:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/acymailing/trunk/code/front/FrontControllers/FrontservicesController.php#L10-L20`.

```php
<?php

namespace AcyMailing\FrontControllers;

use AcyMailing\Classes\HistoryClass;
use AcyMailing\Classes\UserClass;
use AcyMailing\Classes\UserStatClass;
use AcyMailing\Core\AcymController;

class FrontservicesController extends AcymController
{
    public function __construct()
    {
        parent::__construct();
        acym_setNoTemplate();

        $this->publicFrontTasks = [
            'sendinblue',
        ];
    }

    public function listing(): void
    {
        exit;
    }

    public function sendinblue(): void
    {
        // Check security key
        $securityKey = acym_getVar('string', 'seckey');
        $storedKey = $this->config->get('sendinblue_webhooks_seckey');
        if (empty($securityKey) || empty($storedKey) || !hash_equals((string)$storedKey, (string)$securityKey)) exit;

        // Check if sending method is sendinblue
        $mailerMethod = $this->config->get('mailer_method');
        if (!in_array($mailerMethod, ['brevo-smtp', 'sendinblue'])) exit;

        // Get the data passed by Sendinblue
        $data = acym_getJsonData();
        if (empty($data['email'])) exit;

        // Get the user from the email
        $userClass = new UserClass();
        $user = $userClass->getOneByEmail($data['email']);
        if (empty($user)) exit;

        $action = empty($data['event']) ? 'brevo' : $data['event'];

        // Get the related email id if there is one
        $mailId = 0;
        if (!empty($data['campaign name']) && strpos($data['campaign name'], 'AcyMailing Mail ') === 0) {
            $mailId = preg_replace('#^AcyMailing Mail (\d+) \(.*$#Uis', '$1', $data['campaign name']);

            // Register the unsubscription on the email's stats
            if (in_array($action, ['unsubscribe', 'spam'])) {
                acym_query('UPDATE #__acym_user_stat SET unsubscribe = unsubscribe + 1 WHERE user_id = '.intval($user->id).' AND mail_id = '.intval($mailId));
                acym_query('UPDATE #__acym_mail_stat SET unsubscribe_total = unsubscribe_total + 1 WHERE mail_id = '.intval($mailId));
                acym_query('UPDATE #__acym_user_has_list SET status = 0 WHERE user_id = '.intval($user->id));
            }

            if ($action === 'hard_bounce') {
                $userStatClass = new UserStatClass();
                $currentUserStats = $userStatClass->getOneByMailAndUserId($mailId, $user->id);
                if ($currentUserStats->bounce < 1) {
                    acym_query('UPDATE #__acym_mail_stat SET bounce_unique = bounce_unique + 1 WHERE mail_id = '.intval($mailId));
                }
                acym_query('UPDATE #__acym_user_stat SET bounce = bounce + 1 WHERE user_id = '.intval($user->id).' AND mail_id = '.intval($mailId));
            }
        }

        // If found, disable the user and add the reason in their history
        $user->active = 0;
        $userClass->save($user);

        $historyClass = new HistoryClass();
        $historyClass->insert($user->id, $action, ['Brevo'], $mailId);

        exit;
    }
}

```
