Jump to content

[RESOLU] Filtrage d'envoi d'emails


Recommended Posts

Bonjour,

 

Notre boutique en ligne Mon Institut Beauté est actuellement raccordée à un gestionnaire de places de marchés, Shopping-Flux : les produits sont envoyés vers les places de marché, et toutes les commandes Amazon, ebay etc sont remontées vers Prestashop.

 

Toutes les places de marchés interdisent la réutilisation des emails des clients remotnés dans Prestashop pour de la prospection... sachant que le fonctionnement de Prestashop est tel que des emails sont envoyés quand :

- une commande est créé

- le statut d'une commande est changée

 

Pour cette raison, Shopping-Flux fait remonter des emails faux. Le soucis, c'est que ça a fait exploser notre taux d'erreur d'emails envoyés et bloqué notre fonction email sur OVH (notre hébergeur). La fonction a été débloquée. Vu que ce sont des emails fictifs et qu'ils retournent une erreur on souhaite bloquer l'envoi de ces emails pour ne pas redépasser le seuil de tolérance. Ces emails suivent tous ce modèle : "[email protected]"

 

OVH est Shopping-Flux ont affirmé qu'ils ne peuvent pas mettre en place de filtrage d'envoi d'email. L'administrateur d'OVH nous a dit cependant qu'il était possible d'effectuer ce type de filtrage directement depuis les fonctions PHP gérant les emails de Prestashop.

 

Est-ce que qqun voit ce qu'il possible de faire pour bloquer l'envoi de tous les emails "[email protected]" ?

 

Merci !

Edited by MarcKarl (see edit history)
Link to comment
Share on other sites

Je souhaite justement que les emails automatiques soient maintenus, car nous avons des commandes sur notre site et nous devons tenir informé nos clients.

 

Je souhaite juste bloquer l'envoi d'emails pour les places de marché, à savoir que ces emails sont tous envoyés sur cette adresse : "[email protected]". Est-il possible de la filtrer ?

Link to comment
Share on other sites

J'ai regardé le module en question, et il me parait inutile de contacter les développeurs (et c'est un module natif de prestashop, donc impossible de contacter les développeurs il me semble) : le module n'est pas du tout pensé pour faire un filtrage des emails, mais juste pour activer ou non certaines notifications pour tous les contacts.

Link to comment
Share on other sites

Dans www/classes/order, j'ai trouvé OrderHistory.php. Donc si je comprends bien, le code devrait être modifié comme ceci ?

 

Extrait du code original du fichier :

public function addWithemail($autodate = true, $template_vars = false, Context $context = null)
    {
        $order = new Order($this->id_order);

        if (!$this->add($autodate)) {
            return false;
        }

        if (!$this->sendEmail($order, $template_vars)) {
            return false;
        }

        return true;
    }

Extrait du code modifié du fichier :

    public function addWithemail($autodate = true, $template_vars = false, Context $context = null)
    {
        $order = new Order($this->id_order);

        if (!$this->add($autodate)) {
            return false;
        }

        if (!$this->sendEmail($order, $template_vars)) {
            return false;
        }

        if (!strpos($result['email'], "alerts-shopping-flux.com"))
        return true;
    }
Edited by MarcKarl (see edit history)
Link to comment
Share on other sites

non la condition il faut la faire sur le Mail::Send

 

je ne connais pas votre version mais sur 1.6.0.9 ça donnerait 

if (!strpos($result['email'], "alerts-shopping-flux.com"))
Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'],
   null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop);

(je n'ai pas testé)

 

et bien faire votre modif dans un override et pas sur le fichier Core directement

Link to comment
Share on other sites

D'accord, merci ! Par contre... comment faire la modification dans un override ? Je ne suis même pas certain de savoir ce que c'est : est-ce que c'est un fichier complémentaire qui prend le dessus sur la version d'origine ?

 

J'ai Prestashop v1.6.1.4.

 

Voici en pièce jointe le fichier de ma propre version de prestashop, pour être certain que tout soit raccord.

 

Donc en somme, quelle est la procédure pour bloquer l'envoi d'emails sur toutes les adresses "[email protected]"

 

OrderHistory.php ?

Link to comment
Share on other sites

Merci, j'ai effectué une copie du fichier OrderHistory.php dans /www/override/classes/order .

 

Est-ce que le fichier que j'ai uploadé en pièce jointe précédemment a aidé ? Donc maintenant est-ce que le changement dans le nouveau fichier doit être comme ceci ?

 

Extrait du code original du fichier :

public function addWithemail($autodate = true, $template_vars = false, Context $context = null)
    {
        $order = new Order($this->id_order);

        if (!$this->add($autodate)) {
            return false;
        }

        if (!$this->sendEmail($order, $template_vars)) {
            return false;
        }

        return true;
    }

Extrait du code modifié du fichier :

public function addWithemail($autodate = true, $template_vars = false, Context $context = null)
    {
        $order = new Order($this->id_order);

        if (!$this->add($autodate)) {
            return false;
        }

        if (!$this->sendEmail($order, $template_vars)) {
            return false;
        }
        if (!strpos($result['email'], "alerts-shopping-flux.com"))
        Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'], null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop);
        return true;
    }
Link to comment
Share on other sites

bon, reprenons

 

vous ne touchez pas au fichier originel OrderHistory.php

donc vous y remettez la ligne Mail::Send comme à l'origine

 

vous créez un ficher override/classes/order/OrderHistory.php

Dedans, vous mettez :

<?php
class OrderHistory extends OrderHistoryCore
{

}

Dans cette classe (dans l'override), vous recopiez la function addWithemail de la classe d'origine

et vous y ajoutez juste la condition avant la ligne du Mail::Send

 

ensuite vous supprimez le fichier cache/class_index.php pour que l'override soit pris en compte

Link to comment
Share on other sites

C'est là qu'avoir des compétences en php pourrait être intéressant....

 

Donc :

- Ne pas toucher au fichier original, je n'y ai de toute façon pas touché : OK

- Créer le fichier override/classes/order/OrderHistory.php : OK

- J'ai rajouté le bout de code que vous avez posté : OK

 

C'est ici que ça se gâte un peu : est-ce que j'ai correctement inclus la function addWithemail du fichier d'origine dans l'override de la classe ? (function addWithemail en gras, rajout de condition en souligné => EDIT : le gras et le souligné passent pas, dommage)

<?php
class OrderHistory extends OrderHistoryCore
{
    public function sendEmail($order, $template_vars = false)
    {
        $result = Db::getInstance()->getRow('
			SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`
			FROM `'._DB_PREFIX_.'order_history` oh
				LEFT JOIN `'._DB_PREFIX_.'orders` o ON oh.`id_order` = o.`id_order`
				LEFT JOIN `'._DB_PREFIX_.'customer` c ON o.`id_customer` = c.`id_customer`
				LEFT JOIN `'._DB_PREFIX_.'order_state` os ON oh.`id_order_state` = os.`id_order_state`
				LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
			WHERE oh.`id_order_history` = '.(int)$this->id.' AND os.`send_email` = 1');
        if (isset($result['template']) && Validate::isEmail($result['email'])) {
            ShopUrl::cacheMainDomainForShop($order->id_shop);

            $topic = $result['osname'];
            $data = array(
                '{lastname}' => $result['lastname'],
                '{firstname}' => $result['firstname'],
                '{id_order}' => (int)$this->id_order,
                '{order_name}' => $order->getUniqReference()
            );

            if ($result['module_name']) {
                $module = Module::getInstanceByName($result['module_name']);
                if (Validate::isLoadedObject($module) && isset($module->extra_mail_vars) && is_array($module->extra_mail_vars)) {
                    $data = array_merge($data, $module->extra_mail_vars);
                }
            }

            if ($template_vars) {
                $data = array_merge($data, $template_vars);
            }

            $data['{total_paid}'] = Tools::displayPrice((float)$order->total_paid, new Currency((int)$order->id_currency), false);

            if (Validate::isLoadedObject($order)) {
                // Attach invoice and / or delivery-slip if they exists and status is set to attach them
                if (($result['pdf_invoice'] || $result['pdf_delivery'])) {
                    $context = Context::getContext();
                    $invoice = $order->getInvoicesCollection();
                    $file_attachement = array();

                    if ($result['pdf_invoice'] && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) {
                        Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $invoice));
                        $pdf = new PDF($invoice, PDF::TEMPLATE_INVOICE, $context->smarty);
                        $file_attachement['invoice']['content'] = $pdf->render(false);
                        $file_attachement['invoice']['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';
                        $file_attachement['invoice']['mime'] = 'application/pdf';
                    }
                    if ($result['pdf_delivery'] && $order->delivery_number) {
                        $pdf = new PDF($invoice, PDF::TEMPLATE_DELIVERY_SLIP, $context->smarty);
                        $file_attachement['delivery']['content'] = $pdf->render(false);
                        $file_attachement['delivery']['name'] = Configuration::get('PS_DELIVERY_PREFIX', Context::getContext()->language->id, null, $order->id_shop).sprintf('%06d', $order->delivery_number).'.pdf';
                        $file_attachement['delivery']['mime'] = 'application/pdf';
                    }
                } else {
                    $file_attachement = null;
                }
                if (!strpos($result['email'], "alerts-shopping-flux.com"))
                (!Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'],
                    null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop)) {
                    return false;
                }
            }

            ShopUrl::resetMainDomainCache();
        }

        return true;
    }
}

Supprimer le fichier cache/class_index.php sera ok une fois l'étape ci-dessus validée

Edited by MarcKarl (see edit history)
Link to comment
Share on other sites

ok bon je suppose qu'il y a encore plusieurs versions de 1.6.1.4 parce que sur celle que j'ai je n'ai pas ce sendEmail

 

bon du coup, laissez tomber la function AddWithemail

vous copiez-collez à l'identique la function Sendemail dans l'override.

et on va changer plutot la ligne  if (Validate::isLoadedObject($order)) {

par

if (Validate::isLoadedObject($order) && !strpos($result['email'], "alerts-shopping-flux.com")) {
  • Like 1
Link to comment
Share on other sites

Donc pour être sûr, en modifiant cette ligne dans l'override, ça va :

- bloquer l'envoi d'e-mails sur toutes les adresses "[email protected]" lors de la création d'une commande

- et aussi bloquer l'envoi d'e-mails sur toutes les adresses "[email protected]" lors de la modification des statuts de ces commandes

 

Ok j'ai fais ça, merci beaucoup ! C'est par contre un peu étrange qu'il y ait plusieurs versions de fichiers pour une même version de prestashop, je ne pensais pas que c'était possible.

 

Je vais regarder ce que ça donne prochainement, je vous tiens au courant.

Link to comment
Share on other sites

Bon... mauvaise nouvelle, ça n'a pas l'air de fonctionner pour le moment.

 

Je confirme bien que le fichier OrderHistory.php est dans le dossier /www/override/classes/order .

 

Tout est bon dans le code ?

<?php
class OrderHistory extends OrderHistoryCore
{
    public function sendEmail($order, $template_vars = false)
    {
        $result = Db::getInstance()->getRow('
			SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`
			FROM `'._DB_PREFIX_.'order_history` oh
				LEFT JOIN `'._DB_PREFIX_.'orders` o ON oh.`id_order` = o.`id_order`
				LEFT JOIN `'._DB_PREFIX_.'customer` c ON o.`id_customer` = c.`id_customer`
				LEFT JOIN `'._DB_PREFIX_.'order_state` os ON oh.`id_order_state` = os.`id_order_state`
				LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
			WHERE oh.`id_order_history` = '.(int)$this->id.' AND os.`send_email` = 1');
        if (isset($result['template']) && Validate::isEmail($result['email'])) {
            ShopUrl::cacheMainDomainForShop($order->id_shop);

            $topic = $result['osname'];
            $data = array(
                '{lastname}' => $result['lastname'],
                '{firstname}' => $result['firstname'],
                '{id_order}' => (int)$this->id_order,
                '{order_name}' => $order->getUniqReference()
            );

            if ($result['module_name']) {
                $module = Module::getInstanceByName($result['module_name']);
                if (Validate::isLoadedObject($module) && isset($module->extra_mail_vars) && is_array($module->extra_mail_vars)) {
                    $data = array_merge($data, $module->extra_mail_vars);
                }
            }

            if ($template_vars) {
                $data = array_merge($data, $template_vars);
            }

            $data['{total_paid}'] = Tools::displayPrice((float)$order->total_paid, new Currency((int)$order->id_currency), false);

            if (Validate::isLoadedObject($order) && !strpos($result['email'], "alerts-shopping-flux.com")) {
                // Attach invoice and / or delivery-slip if they exists and status is set to attach them
                if (($result['pdf_invoice'] || $result['pdf_delivery'])) {
                    $context = Context::getContext();
                    $invoice = $order->getInvoicesCollection();
                    $file_attachement = array();

                    if ($result['pdf_invoice'] && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) {
                        Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $invoice));
                        $pdf = new PDF($invoice, PDF::TEMPLATE_INVOICE, $context->smarty);
                        $file_attachement['invoice']['content'] = $pdf->render(false);
                        $file_attachement['invoice']['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';
                        $file_attachement['invoice']['mime'] = 'application/pdf';
                    }
                    if ($result['pdf_delivery'] && $order->delivery_number) {
                        $pdf = new PDF($invoice, PDF::TEMPLATE_DELIVERY_SLIP, $context->smarty);
                        $file_attachement['delivery']['content'] = $pdf->render(false);
                        $file_attachement['delivery']['name'] = Configuration::get('PS_DELIVERY_PREFIX', Context::getContext()->language->id, null, $order->id_shop).sprintf('%06d', $order->delivery_number).'.pdf';
                        $file_attachement['delivery']['mime'] = 'application/pdf';
                    }
                } else {
                    $file_attachement = null;
                }

                if (!Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'],
                    null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop)) {
                    return false;
                }
            }

            ShopUrl::resetMainDomainCache();
        }

        return true;
    }
}
Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

Re-boujour,

 

Oui, la modification est toujours opérationnelle.... jusqu'à ce week end. Pour le moment je n'ai pas encore pu tester la chose mais vous tombez à pic !

 

Ce matin nous avons mis à jour notre version Prestashop (la dernière mise à jour 1.6.1.11), et je souhaite savoir si la modification est toujours opérationnelle sur cette nouvelle version. J'ai procédé aux même étapes pour remettre le filtrage en route mais pour le moment je ne sais pas si cela fonctionne ou non.

 

Marc

Link to comment
Share on other sites

Je ne sais pas, il faudrait analyser le code.

 

Mais ce que je vous conseillerai, c'est de laisser tomber cette modif, qui intervient uniquement lors des changements de statut de commande, et de plutot overrider la class Mail

Perso, j'ai simplement ajouté ceci en haut de la function Send

if (strpos($to, "alerts-shopping-flux.com"))
return true;
Link to comment
Share on other sites

Dans la même logique précédente, est-ce que je dois :

 

- Copier sur le PC le fichier /www/classes/Mail.php ?

- Rajouter le bout de code dans la function Send du fichier ?

- Copier la nouvelle version du fichier dans /www/override/classes ?

- Supprimer le fichier /www/override/classes/index.php ?

 

 

Le code doit être comme ceci ?

    public static function Send($id_lang, $template, $subject, $template_vars, $to,
        $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
        $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
    {
        if (strpos($to, "alerts-shopping-flux.com"))
return true;
        if (!$id_shop) {
            $id_shop = Context::getContext()->shop->id;
        }
Link to comment
Share on other sites

oui c'est ça

si "alerts-shopping-flux.com" est compris dans $to, on execute pas le reste de la fonction Send.

 

Votre override doit commencer par :

<?php
class Mail extends MailCore {
    public static function Send($id_lang, $template, $subject, $template_vars, $to,
                                $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
                                $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null)
    {
       if (strpos($to, "alerts-shopping-flux.com"))
            return true;
Link to comment
Share on other sites

Mon code commence comme ceci, je ne suis pas sûr de tout comprendre. J'ai normalement intégré correctement le bout de code dans la function send (dites moi s'il y a une erreur), mais je vois pas où mettre le deuxième bout de code que vous me donnez : j'ai trouvé class MailCore extends ObjectModel au début, mais non class Mail extends MailCore. Pardonnez-moi, mes connaissance en php sont très limitées

<?php
/**
 * 2007-2016 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <[email protected]>
 * @copyright 2007-2016 PrestaShop SA
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 */

include_once(_PS_SWIFT_DIR_.'swift_required.php');

class MailCore extends ObjectModel
{
    public $id;

    /** @var string Recipient */
    public $recipient;

    /** @var string Template */
    public $template;

    /** @var string Subject */
    public $subject;

    /** @var int Language ID */
    public $id_lang;

    /** @var int Timestamp */
    public $date_add;

    /**
     * @see ObjectModel::$definition
     */
    public static $definition = array(
        'table' => 'mail',
        'primary' => 'id_mail',
        'fields' => array(
            'recipient' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'copy_post' => false, 'required' => true, 'size' => 126),
            'template' => array('type' => self::TYPE_STRING, 'validate' => 'isTplName', 'copy_post' => false, 'required' => true, 'size' => 62),
            'subject' => array('type' => self::TYPE_STRING, 'validate' => 'isMailSubject', 'copy_post' => false, 'required' => true, 'size' => 254),
            'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false, 'required' => true),
            'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false, 'required' => true),
        ),
    );

    const TYPE_HTML = 1;
    const TYPE_TEXT = 2;
    const TYPE_BOTH = 3;

    /**
     * Send Email
     *
     * @param int $id_lang Language ID of the email (to translate the template)
     * @param string $template Template: the name of template not be a var but a string !
     * @param string $subject Subject of the email
     * @param string $template_vars Template variables for the email
     * @param string $to To email
     * @param string $to_name To name
     * @param string $from From email
     * @param string $from_name To email
     * @param array $file_attachment Array with three parameters (content, mime and name). You can use an array of array to attach multiple files
     * @param bool $mode_smtp SMTP mode (deprecated)
     * @param string $template_path Template path
     * @param bool $die Die after error
     * @param int $id_shop Shop ID
     * @param string $bcc Bcc recipient (email address)
     * @param string $reply_to Email address for setting the Reply-To header
     * @return bool|int Whether sending was successful. If not at all, false, otherwise amount of recipients succeeded.
     */
    public static function Send($id_lang, $template, $subject, $template_vars, $to,
        $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
        $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
    {
        if (strpos($to, "alerts-shopping-flux.com"))
return true;
        if (!$id_shop) {
            $id_shop = Context::getContext()->shop->id;
        }

        $configuration = Configuration::getMultiple(array(
            'PS_SHOP_EMAIL',
            'PS_MAIL_METHOD',
            'PS_MAIL_SERVER',
            'PS_MAIL_USER',
            'PS_MAIL_PASSWD',
            'PS_SHOP_NAME',
            'PS_MAIL_SMTP_ENCRYPTION',
            'PS_MAIL_SMTP_PORT',
            'PS_MAIL_TYPE'
        ), null, null, $id_shop);

        // Returns immediatly if emails are deactivated
        if ($configuration['PS_MAIL_METHOD'] == 3) {
            return true;
        }

Link to comment
Share on other sites

  • 2 months later...

Bonjour,

 

Est-ce que c'est correct comme ceci ?

 

J'ai repris le fichier d'origine et copié-collé le bout de code que vous m'avez transmis. Mais, on retrouve deux fois "function Send" : une fois au début, et une fois en dessous du commentaire "  /**
     * Send Email
     *
     * @param int $id_lang"

<?php
class Mail extends MailCore {
    public static function Send($id_lang, $template, $subject, $template_vars, $to,
                                $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
                                $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null)
    {
       if (strpos($to, "alerts-shopping-flux.com"))
            return true;
/**
 * 2007-2016 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <[email protected]>
 * @copyright 2007-2016 PrestaShop SA
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 */

include_once(_PS_SWIFT_DIR_.'swift_required.php');

class MailCore extends ObjectModel
{
    public $id;

    /** @var string Recipient */
    public $recipient;

    /** @var string Template */
    public $template;

    /** @var string Subject */
    public $subject;

    /** @var int Language ID */
    public $id_lang;

    /** @var int Timestamp */
    public $date_add;

    /**
     * @see ObjectModel::$definition
     */
    public static $definition = array(
        'table' => 'mail',
        'primary' => 'id_mail',
        'fields' => array(
            'recipient' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'copy_post' => false, 'required' => true, 'size' => 126),
            'template' => array('type' => self::TYPE_STRING, 'validate' => 'isTplName', 'copy_post' => false, 'required' => true, 'size' => 62),
            'subject' => array('type' => self::TYPE_STRING, 'validate' => 'isMailSubject', 'copy_post' => false, 'required' => true, 'size' => 254),
            'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false, 'required' => true),
            'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false, 'required' => true),
        ),
    );

    const TYPE_HTML = 1;
    const TYPE_TEXT = 2;
    const TYPE_BOTH = 3;

    /**
     * Send Email
     *
     * @param int $id_lang Language ID of the email (to translate the template)
     * @param string $template Template: the name of template not be a var but a string !
     * @param string $subject Subject of the email
     * @param string $template_vars Template variables for the email
     * @param string $to To email
     * @param string $to_name To name
     * @param string $from From email
     * @param string $from_name To email
     * @param array $file_attachment Array with three parameters (content, mime and name). You can use an array of array to attach multiple files
     * @param bool $mode_smtp SMTP mode (deprecated)
     * @param string $template_path Template path
     * @param bool $die Die after error
     * @param int $id_shop Shop ID
     * @param string $bcc Bcc recipient (email address)
     * @param string $reply_to Email address for setting the Reply-To header
     * @return bool|int Whether sending was successful. If not at all, false, otherwise amount of recipients succeeded.
     */
    public static function Send($id_lang, $template, $subject, $template_vars, $to,
        $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
        $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
    {
        if (!$id_shop) {
            $id_shop = Context::getContext()->shop->id;
        }

        $configuration = Configuration::getMultiple(array(
            'PS_SHOP_EMAIL',
            'PS_MAIL_METHOD',
            'PS_MAIL_SERVER',
            'PS_MAIL_USER',
            'PS_MAIL_PASSWD',
            'PS_SHOP_NAME',
            'PS_MAIL_SMTP_ENCRYPTION',
            'PS_MAIL_SMTP_PORT',
            'PS_MAIL_TYPE'
        ), null, null, $id_shop);

        // Returns immediatly if emails are deactivated
        if ($configuration['PS_MAIL_METHOD'] == 3) {
            return true;
        }

        $theme_path = _PS_THEME_DIR_;

        // Get the path of theme by id_shop if exist
        if (is_numeric($id_shop) && $id_shop) {
            $shop = new Shop((int)$id_shop);
            $theme_name = $shop->getTheme();

            if (_THEME_NAME_ != $theme_name) {
                $theme_path = _PS_ROOT_DIR_.'/themes/'.$theme_name.'/';
            }
        }

        if (!isset($configuration['PS_MAIL_SMTP_ENCRYPTION']) || Tools::strtolower($configuration['PS_MAIL_SMTP_ENCRYPTION']) === 'off') {
            $configuration['PS_MAIL_SMTP_ENCRYPTION'] = false;
        }
        if (!isset($configuration['PS_MAIL_SMTP_PORT'])) {
            $configuration['PS_MAIL_SMTP_PORT'] = 'default';
        }

        // Sending an e-mail can be of vital importance for the merchant, when his password is lost for example, so we must not die but do our best to send the e-mail

        if (!isset($from) || !Validate::isEmail($from)) {
            $from = $configuration['PS_SHOP_EMAIL'];
        }

        if (!Validate::isEmail($from)) {
            $from = null;
        }

        // $from_name is not that important, no need to die if it is not valid
        if (!isset($from_name) || !Validate::isMailName($from_name)) {
            $from_name = $configuration['PS_SHOP_NAME'];
        }
        if (!Validate::isMailName($from_name)) {
            $from_name = null;
        }

        // It would be difficult to send an e-mail if the e-mail is not valid, so this time we can die if there is a problem
        if (!is_array($to) && !Validate::isEmail($to)) {
            Tools::dieOrLog(Tools::displayError('Error: parameter "to" is corrupted'), $die);
            return false;
        }

        // if bcc is not null, make sure it's a vaild e-mail
        if (!is_null($bcc) && !is_array($bcc) && !Validate::isEmail($bcc)) {
            Tools::dieOrLog(Tools::displayError('Error: parameter "bcc" is corrupted'), $die);
            $bcc = null;
        }

        if (!is_array($template_vars)) {
            $template_vars = array();
        }

        // Do not crash for this error, that may be a complicated customer name
        if (is_string($to_name) && !empty($to_name) && !Validate::isMailName($to_name)) {
            $to_name = null;
        }

        if (!Validate::isTplName($template)) {
            Tools::dieOrLog(Tools::displayError('Error: invalid e-mail template'), $die);
            return false;
        }

        if (!Validate::isMailSubject($subject)) {
            Tools::dieOrLog(Tools::displayError('Error: invalid e-mail subject'), $die);
            return false;
        }

        /* Construct multiple recipients list if needed */
        $message = Swift_Message::newInstance();
        if (is_array($to) && isset($to)) {
            foreach ($to as $key => $addr) {
                $addr = trim($addr);
                if (!Validate::isEmail($addr)) {
                    Tools::dieOrLog(Tools::displayError('Error: invalid e-mail address'), $die);
                    return false;
                }

                if (is_array($to_name) && $to_name && is_array($to_name) && Validate::isGenericName($to_name[$key])) {
                    $to_name = $to_name[$key];
                }

                $to_name = (($to_name == null || $to_name == $addr) ? '' : self::mimeEncode($to_name));
                $message->addTo($addr, $to_name);
            }
            $to_plugin = $to[0];
        } else {
            /* Simple recipient, one address */
            $to_plugin = $to;
            $to_name = (($to_name == null || $to_name == $to) ? '' : self::mimeEncode($to_name));
            $message->addTo($to, $to_name);
        }
        if (isset($bcc)) {
            $message->addBcc($bcc);
        }

        try {
            /* Connect with the appropriate configuration */
            if ($configuration['PS_MAIL_METHOD'] == 2) {
                if (empty($configuration['PS_MAIL_SERVER']) || empty($configuration['PS_MAIL_SMTP_PORT'])) {
                    Tools::dieOrLog(Tools::displayError('Error: invalid SMTP server or SMTP port'), $die);
                    return false;
                }

                $connection = Swift_SmtpTransport::newInstance($configuration['PS_MAIL_SERVER'], $configuration['PS_MAIL_SMTP_PORT'], $configuration['PS_MAIL_SMTP_ENCRYPTION'])
                    ->setUsername($configuration['PS_MAIL_USER'])
                    ->setPassword($configuration['PS_MAIL_PASSWD']);

            } else {
                $connection = Swift_MailTransport::newInstance();
            }

            if (!$connection) {
                return false;
            }
            $swift = Swift_Mailer::newInstance($connection);
            /* Get templates content */
            $iso = Language::getIsoById((int)$id_lang);
            if (!$iso) {
                Tools::dieOrLog(Tools::displayError('Error - No ISO code for email'), $die);
                return false;
            }
            $iso_template = $iso.'/'.$template;

            $module_name = false;
            $override_mail = false;

            // get templatePath
            if (preg_match('#'.$shop->physical_uri.'modules/#', str_replace(DIRECTORY_SEPARATOR, '/', $template_path)) && preg_match('#modules/([a-z0-9_-]+)/#ui', str_replace(DIRECTORY_SEPARATOR, '/', $template_path), $res)) {
                $module_name = $res[1];
            }

            if ($module_name !== false && (file_exists($theme_path.'modules/'.$module_name.'/mails/'.$iso_template.'.txt') ||
                    file_exists($theme_path.'modules/'.$module_name.'/mails/'.$iso_template.'.html'))) {
                $template_path = $theme_path.'modules/'.$module_name.'/mails/';
            } elseif (file_exists($theme_path.'mails/'.$iso_template.'.txt') || file_exists($theme_path.'mails/'.$iso_template.'.html')) {
                $template_path = $theme_path.'mails/';
                $override_mail  = true;
            }
            if (!file_exists($template_path.$iso_template.'.txt') && ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT)) {
                Tools::dieOrLog(Tools::displayError('Error - The following e-mail template is missing:').' '.$template_path.$iso_template.'.txt', $die);
                return false;
            } elseif (!file_exists($template_path.$iso_template.'.html') && ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_HTML)) {
                Tools::dieOrLog(Tools::displayError('Error - The following e-mail template is missing:').' '.$template_path.$iso_template.'.html', $die);
                return false;
            }
            $template_html = '';
            $template_txt = '';
            Hook::exec('actionEmailAddBeforeContent', array(
                'template' => $template,
                'template_html' => &$template_html,
                'template_txt' => &$template_txt,
                'id_lang' => (int)$id_lang
            ), null, true);
            $template_html .= Tools::file_get_contents($template_path.$iso_template.'.html');
            $template_txt .= strip_tags(html_entity_decode(Tools::file_get_contents($template_path.$iso_template.'.txt'), null, 'utf-8'));
            Hook::exec('actionEmailAddAfterContent', array(
                'template' => $template,
                'template_html' => &$template_html,
                'template_txt' => &$template_txt,
                'id_lang' => (int)$id_lang
            ), null, true);
            if ($override_mail && file_exists($template_path.$iso.'/lang.php')) {
                include_once($template_path.$iso.'/lang.php');
            } elseif ($module_name && file_exists($theme_path.'mails/'.$iso.'/lang.php')) {
                include_once($theme_path.'mails/'.$iso.'/lang.php');
            } elseif (file_exists(_PS_MAIL_DIR_.$iso.'/lang.php')) {
                include_once(_PS_MAIL_DIR_.$iso.'/lang.php');
            } else {
                Tools::dieOrLog(Tools::displayError('Error - The language file is missing for:').' '.$iso, $die);
                return false;
            }

            /* Create mail and attach differents parts */
            $subject = '['.Configuration::get('PS_SHOP_NAME', null, null, $id_shop).'] '.$subject;
            $message->setSubject($subject);

            $message->setCharset('utf-8');

            /* Set Message-ID - getmypid() is blocked on some hosting */
            $message->setId(Mail::generateId());

            if (!($reply_to && Validate::isEmail($reply_to))) {
                $reply_to = $from;
            }

            if (isset($reply_to) && $reply_to) {
                $message->setReplyTo($reply_to);
            }

            $template_vars = array_map(array('Tools', 'htmlentitiesDecodeUTF8'), $template_vars);
            $template_vars = array_map(array('Tools', 'stripslashes'), $template_vars);

            if (Configuration::get('PS_LOGO_MAIL') !== false && file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO_MAIL', null, null, $id_shop))) {
                $logo = _PS_IMG_DIR_.Configuration::get('PS_LOGO_MAIL', null, null, $id_shop);
            } else {
                if (file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO', null, null, $id_shop))) {
                    $logo = _PS_IMG_DIR_.Configuration::get('PS_LOGO', null, null, $id_shop);
                } else {
                    $template_vars['{shop_logo}'] = '';
                }
            }
            ShopUrl::cacheMainDomainForShop((int)$id_shop);
            /* don't attach the logo as */
            if (isset($logo)) {
                $template_vars['{shop_logo}'] = $message->embed(Swift_Image::fromPath($logo));
            }

            if ((Context::getContext()->link instanceof Link) === false) {
                Context::getContext()->link = new Link();
            }

            $template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
            $template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id, null, false, $id_shop);
            $template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id, null, false, $id_shop);
            $template_vars['{guest_tracking_url}'] = Context::getContext()->link->getPageLink('guest-tracking', true, Context::getContext()->language->id, null, false, $id_shop);
            $template_vars['{history_url}'] = Context::getContext()->link->getPageLink('history', true, Context::getContext()->language->id, null, false, $id_shop);
            $template_vars['{color}'] = Tools::safeOutput(Configuration::get('PS_MAIL_COLOR', null, null, $id_shop));
            // Get extra template_vars
            $extra_template_vars = array();
            Hook::exec('actionGetExtraMailTemplateVars', array(
                'template' => $template,
                'template_vars' => $template_vars,
                'extra_template_vars' => &$extra_template_vars,
                'id_lang' => (int)$id_lang
            ), null, true);
            $template_vars = array_merge($template_vars, $extra_template_vars);
            $swift->registerPlugin(new Swift_Plugins_DecoratorPlugin(array($to_plugin => $template_vars)));
            if ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT) {
                $message->addPart($template_txt, 'text/plain', 'utf-8');
            }
            if ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_HTML) {
                $message->addPart($template_html, 'text/html', 'utf-8');
            }
            if ($file_attachment && !empty($file_attachment)) {
                // Multiple attachments?
                if (!is_array(current($file_attachment))) {
                    $file_attachment = array($file_attachment);
                }

                foreach ($file_attachment as $attachment) {
                    if (isset($attachment['content']) && isset($attachment['name']) && isset($attachment['mime'])) {
                        $message->attach(Swift_Attachment::newInstance()->setFilename($attachment['name'])->setContentType($attachment['mime'])->setBody($attachment['content']));
                    }
                }
            }
            /* Send mail */
            $message->setFrom(array($from => $from_name));
            $send = $swift->send($message);

            ShopUrl::resetMainDomainCache();

            if ($send && Configuration::get('PS_LOG_EMAILS')) {
                $mail = new Mail();
                $mail->template = Tools::substr($template, 0, 62);
                $mail->subject = Tools::substr($subject, 0, 254);
                $mail->id_lang = (int)$id_lang;
                $recipients_to = $message->getTo();
                $recipients_cc = $message->getCc();
                $recipients_bcc = $message->getBcc();
                if (!is_array($recipients_to)) {
                    $recipients_to = array();
                }
                if (!is_array($recipients_cc)) {
                    $recipients_cc = array();
                }
                if (!is_array($recipients_bcc)) {
                    $recipients_bcc = array();
                }
                foreach (array_merge($recipients_to, $recipients_cc, $recipients_bcc) as $email => $recipient_name) {
                    /** @var Swift_Address $recipient */
                    $mail->id = null;
                    $mail->recipient = Tools::substr($email, 0, 126);
                    $mail->add();
                }
            }

            return $send;
        } catch (Swift_SwiftException $e) {
            PrestaShopLogger::addLog(
                'Swift Error: '.$e->getMessage(),
                3,
                null,
                'Swift_Message'
            );

            return false;
        }
    }

    /**
     * @param $id_mail Mail ID
     * @return bool Whether removal succeeded
     */
    public static function eraseLog($id_mail)
    {
        return Db::getInstance()->delete('mail', 'id_mail = '.(int)$id_mail);
    }

    /**
     * @return bool
     */
    public static function eraseAllLogs()
    {
        return Db::getInstance()->execute('TRUNCATE TABLE '._DB_PREFIX_.'mail');
    }

    /**
     * Send a test email
     *
     * @param bool $smtp_checked Is SMTP checked?
     * @param string $smtp_server SMTP Server hostname
     * @param string $content Content of the email
     * @param string $subject Subject of the email
     * @param bool $type Deprecated
     * @param string $to To email address
     * @param string $from From email address
     * @param string $smtp_login SMTP login name
     * @param string $smtp_password SMTP password
     * @param int $smtp_port SMTP Port
     * @param bool|string $smtp_encryption Encryption type. "off" or false disable encryption.
     * @return bool|string True if succeeded, otherwise the error message
     */
    public static function sendMailTest($smtp_checked, $smtp_server, $content, $subject, $type, $to, $from, $smtp_login, $smtp_password, $smtp_port = 25, $smtp_encryption)
    {
        $result = false;
        try {
            if ($smtp_checked) {
                if (Tools::strtolower($smtp_encryption) === 'off') {
                    $smtp_encryption = false;
                }
                $smtp = Swift_SmtpTransport::newInstance($smtp_server, $smtp_port, $smtp_encryption)
                    ->setUsername($smtp_login)
                    ->setPassword($smtp_password);
                $swift = Swift_Mailer::newInstance($smtp);
            } else {
                $swift = Swift_Mailer::newInstance(Swift_MailTransport::newInstance());
            }

            $message = Swift_Message::newInstance();

            $message
                ->setFrom($from)
                ->setTo($to)
                ->setSubject($subject)
                ->setBody($content);

            if ($swift->send($message)) {
                $result = true;
            }
        } catch (Swift_SwiftException $e) {
            $result = $e->getMessage();
        }

        return $result;
    }

    /**
     * This method is used to get the translation for email Object.
     * For an object is forbidden to use htmlentities,
     * we have to return a sentence with accents.
     *
     * @param string $string raw sentence (write directly in file)
     * @return mixed
     */
    public static function l($string, $id_lang = null, Context $context = null)
    {
        global $_LANGMAIL;

        if (!$context) {
            $context = Context::getContext();
        }
        if ($id_lang == null) {
            $id_lang = (!isset($context->language) || !is_object($context->language)) ? (int)Configuration::get('PS_LANG_DEFAULT') : (int)$context->language->id;
        }
        $iso_code = Language::getIsoById((int)$id_lang);

        $file_core = _PS_ROOT_DIR_.'/mails/'.$iso_code.'/lang.php';
        if (Tools::file_exists_cache($file_core) && empty($_LANGMAIL)) {
            include($file_core);
        }

        $file_theme = _PS_THEME_DIR_.'mails/'.$iso_code.'/lang.php';
        if (Tools::file_exists_cache($file_theme)) {
            include($file_theme);
        }

        if (!is_array($_LANGMAIL)) {
            return (str_replace('"', '"', $string));
        }

        $key = str_replace('\'', '\\\'', $string);
        return str_replace('"', '"', Tools::stripslashes((array_key_exists($key, $_LANGMAIL) && !empty($_LANGMAIL[$key])) ? $_LANGMAIL[$key] : $string));
    }

    /* Rewrite of Swift_Message::generateId() without getmypid() */
    protected static function generateId($idstring = null)
    {
        $midparams = array(
            'utctime' => gmstrftime('%Y%m%d%H%M%S'),
            'randint' => mt_rand(),
            'customstr' => (preg_match("/^(?<!\\.)[a-z0-9\\.]+(?!\\.)\$/iD", $idstring) ? $idstring : "swift") ,
            'hostname' => ((isset($_SERVER['SERVER_NAME']) && !empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : php_uname('n')),
        );
        return vsprintf("%s.%d.%s@%s", $midparams);
    }

    /**
     * Check if a multibyte character set is used for the data
     *
     * @param string $data Data
     * @return bool Whether the string uses a multibyte character set
     */
    public static function isMultibyte($data)
    {
        $length = Tools::strlen($data);
        for ($i = 0; $i < $length; $i++) {
            if (ord(($data[$i])) > 128) {
                return true;
            }
        }
        return false;
    }

    /**
     * MIME encode the string
     *
     * @param string $string The string to encode
     * @param string $charset The character set to use
     * @param string $newline The newline character(s)
     * @return mixed|string MIME encoded string
     */
    public static function mimeEncode($string, $charset = 'UTF-8', $newline = "\r\n")
    {
        if (!self::isMultibyte($string) && Tools::strlen($string) < 75) {
            return $string;
        }

        $charset = Tools::strtoupper($charset);
        $start = '=?'.$charset.'?B?';
        $end = '?=';
        $sep = $end.$newline.' '.$start;
        $length = 75 - Tools::strlen($start) - Tools::strlen($end);
        $length = $length - ($length % 4);

        if ($charset === 'UTF-8') {
            $parts = array();
            $maxchars = floor(($length * 3) / 4);
            $stringLength = Tools::strlen($string);

            while ($stringLength > $maxchars) {
                $i = (int)$maxchars;
                $result = ord($string[$i]);

                while ($result >= 128 && $result <= 191) {
                    $result = ord($string[--$i]);
                }

                $parts[] = base64_encode(Tools::substr($string, 0, $i));
                $string = Tools::substr($string, $i);
                $stringLength = Tools::strlen($string);
            }

            $parts[] = base64_encode($string);
            $string = implode($sep, $parts);
        } else {
            $string = chunk_split(base64_encode($string), $length, $sep);
            $string = preg_replace('/'.preg_quote($sep).'$/', '', $string);
        }

        return $start.$string.$end;
    }
}


Link to comment
Share on other sites

non

 

vous créez un fichier dans override/classes qui s'appelle Mail.php

dans ce fichier vous déclarez votre classe

<?php
class Mail extends MailCore {

}

à l'intérieur de la classe (entre { et } ) vous copiez-collez votre function Send à l'identique de celle qui se trouve dans classes/Mail.php

 

au tout début de cette fonction, vous ajoutez la condition

if (strpos($to, "alerts-shopping-flux.com"))
return true;

qui a pour but de sortir de la fonction si "alerts-shopping-flux.com" est detecté dans le champ $to.

donc le reste du code sera ignoré.

 

une fois en place, vous pouvez supprimer l'autre override, et supprimer le class-index.

Link to comment
Share on other sites

J'ai créé le fichier Mail.php dans override/classes, et en voici le contenu :

<?php
class Mail extends MailCore {
	if (strpos($to, "alerts-shopping-flux.com"))
return true;
	public static function Send($id_lang, $template, $subject, $template_vars, $to,
        $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
        $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
}

Pour supprimer l'ancien override, je suppose que je :

- supprime mon ancien fichier /override/classes/order/OrderHistory.php ?

- puis ensuite remette un fichier index.php en se basant ceux présents dans les dossier voisins ?

 

 

Supprimer le class-index : supprimer le fichier /override/classes/index.php ?

Link to comment
Share on other sites

  • 1 month later...

Bonjour

 

Confronté au mêmsoucis avec les places de marchés j'ai suivi  la procédure, (un grand merci à ChDUP)  cependant j'obtiens une erreur de syntaxe avec le "if"

Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) in /var/www/dev26/override/classes/Mail.php on line 3

Voici mon code /override/classes/Mail.php :

<?php
class Mail extends MailCore {
if (strpos($to, "alerts-shopping-flux.com"))
return true;
if (strpos($to, "clemarche.com"))
return true;
​public static function Send($id_lang, $template, $subject, $template_vars, $to,
        $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
        $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
}

Si quelqu'un a une piste car je vois pas le souci,  la syntaxe m'a l'air correct.

 

Merci

Link to comment
Share on other sites

De cette manière alors ?

<?php
class Mail extends MailCore {
​public static function Send($id_lang, $template, $subject, $template_vars, $to,
        if (strpos($to, "alerts-shopping-flux.com")) return true;
        if (strpos($to, "clemarche.com")) return true;
        $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
        $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
}
Link to comment
Share on other sites

mais non !

pourquoi est-ce que vous coupez les paramètres de la function

 

faites un copié-collé :

<?php
class Mail extends MailCore {

​public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null) {
    if (strpos($to, "alerts-shopping-flux.com"))
        return true;
    if (strpos($to, "clemarche.com"))
        return true;

Dessous, vous laissez le contenu de la function Send d'origine

Vous refermez bien la function par un }

puis la class par un autre }

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 7 months later...

Bonjour, je suis spammée par des emails qui finissent tous par qq.com. j'ai suivi la démarche ci-dessus mais maintenant je ne reçois plus mes propres tests de formulaire... et ma table elle continue à se remplir de spam, ex de message :

注册就送28: www.904669.com/? 独创千炮,AG捕鱼王与您“千炮”相约.炮火所指无鱼...

 

Je ne sais plus quoi faire pour stopper cette infection massive...

 

<?php
class Mail extends MailCore {
	

public static function Send($id_lang, $template, $subject, $template_vars, $to,
		$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
		$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null)
	{
		 
		 
		 if (strpos($to, "qq.com"))
        return false;
		
		
		
		$configuration ...

 

merci de votre aide.

 

Link to comment
Share on other sites

  • 1 year later...
  • 6 months later...

Bonjour,

 j'ai besoin de ne pas envoyer un mail du module colissimo officiel (mai automatique qui n'est pas rattaché aux statuts).

Peut-on filtre pour ne pas envoyer ce mail?

J'ai des infos comme le modlèle de mail: colissimo_handling_shipment ou Envoi de la commande .... en cours. ou tous les mails de ce module.

Un solution à ce problème pour presta 1.6?

merci pour votre aide

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...