Jump to content

Mail Alert New Order will send duplicate email


Joey

Recommended Posts

we are using PS1.7.3 and just upgraded MailAlert to 2.2.1. Before upgraded to 2.2.1, there was no issue on this.

Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.0.33

After upgraded, we found that when have new order received, the new order notification will send duplicate email. I had tried to reset the mailalert module but still same. I checked in the advanced setting > mail, only new order will have duplicate problem. order_conf and payment mail only send one times per order without problem.

Can anyone help to solve this issues? Thanks!

 

Regards

 

 

 

Link to comment
Share on other sites

Attached is the 2.2.1 source code from the ps_emailalerts.php, pls see anyone can assist me to solve the problem, I tried restore the mailalerts 2.0.1 old version folder but still not work, still received duplicate mail for each order.

 

        // Shop iso
        $iso = Language::getIsoById((int) Configuration::get('PS_LANG_DEFAULT'));

        // Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
        $merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->merchant_mails);
        foreach ($merchant_mails as $merchant_mail) {
            // Default language
            $mail_id_lang = $id_lang;
            $mail_iso = $iso;

            // Use the merchant lang if he exists as an employee
            $results = Db::getInstance()->executeS('
                SELECT `id_lang` FROM `'._DB_PREFIX_.'employee`
                WHERE `email` = \''.pSQL($merchant_mail).'\'
            ');
            if ($results) {
                $user_iso = Language::getIsoById((int) $results[0]['id_lang']);
                if ($user_iso) {
                    $mail_id_lang = (int) $results[0]['id_lang'];
                    $mail_iso = $user_iso;
                }
            }

            $dir_mail = false;
            if (file_exists(dirname(__FILE__).'/mails/'.$mail_iso.'/new_order.txt') &&
                file_exists(dirname(__FILE__).'/mails/'.$mail_iso.'/new_order.html')) {
                $dir_mail = dirname(__FILE__).'/mails/';
            }

            if (file_exists(_PS_MAIL_DIR_.$mail_iso.'/new_order.txt') &&
                file_exists(_PS_MAIL_DIR_.$mail_iso.'/new_order.html')) {
                $dir_mail = _PS_MAIL_DIR_;
            }

            if ($dir_mail) {
                Mail::Send(
                    $mail_id_lang,
                    'new_order',
                    sprintf(Mail::l('New order : #%d - %s', $mail_id_lang), $order->id, $order->reference),
                    $template_vars,
                    $merchant_mail,
                    null,
                    $configuration['PS_SHOP_EMAIL'],
                    $configuration['PS_SHOP_NAME'],
                    null,
                    null,
                    $dir_mail,
                    null,
                    $id_shop
                );
            }
        }
    }
 

Link to comment
Share on other sites

I found some thing related:

I had restored the backup in testing machine, it is using same version of pretsashop and mailalert modules, it only send one mail for new order, but If I click reset the mail alerts modules, it will change to send duplicate mail on new order.

It was really very strange and don't know where is the problem now, same code, same database, same OS. 

To found out the problem, I want to know what will be done if I click the "RESET" in the mailalert modules, then I can try to find out the difference on the source code, hook position, database, etc... between before reset and after reset.

Anyone know what will be done for this "RESET" action?

 

Thanks!

 

Regards

 

 

 

 

 

 

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...