Jump to content

My mails send two times


Recommended Posts

Hi guys !

So I created a module who get information from a form about a product, and then send it by mail to an employee and the person who fill out the form.

My problem is, when I click on the submit button, mails send two times...

Here is my function :

    public function postProcess()
    {
        parent::postProcess();

        if (Tools::isSubmit('submit_devis')) {
            $prenom = Tools::getValue('prenom');
            $nom = Tools::getValue('nom');
            $email = Tools::getValue('email');
            $tel = Tools::getValue('tel');
            $lit = Tools::getValue('lit');
            $ville = Tools::getValue('ville');
            $numeroclient= Tools::getValue('numeroclient');
            $largeur_lit = Tools::getValue('largeur_lit');
            $panneaux = Tools::getValue('panneaux');
            $coloris = Tools::getValue('coloris');
            $couleur_lit = Tools::getValue('couleur_lit');
            $pietement = Tools::getValue('pietement');
            $releve = Tools::getValue('releve');
            $releve_droite = Tools::getValue('releve_droit');
            $releve_gauche = Tools::getValue('releve_gauche');
            $lattes = Tools::getValue('lattes');
            $lattes_droite = Tools::getValue('lattes_droit');
            $lattes_gauche = Tools::getValue('lattes_gauche');
            $barrieres = Tools::getValue('barrieres');
            $potence = Tools::getValue('potence');

            if ($lit == 1) {
                Mail::Send(
                    (int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id
                    'devis', // email template file to be use
                    '******************', // email subject
                    array(
                        '{email}' => $email,
                        '{prenom}' => $prenom,
                        '{nom}' => $nom,
                        '{tel}' => $tel,
                        '{lit}' => $lit,
                        '{long_lit}' => $largeur_lit,
                        '{panneaux}' => $panneaux,
                        '{coloris}' => $coloris,
                        '{couleur_lit}' => $couleur_lit,
                        '{pietement}' => $pietement,
                        '{releve}' => $releve,
                        '{lattes}' => $lattes,
                        '{barrieres}' => $barrieres,
                        '{potence}' => $potence
                    ),
                    $email, // receiver email address
                    NULL, //receiver name
                    '[email protected]', //from email address
                    NULL  //from name
                );

                Mail::Send(
                    (int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id
                    'devis_2', // email template file to be use
                    ' Demande de devis en ligne via le configurateur 3D', // email subject
                    array(
                        '{email}' => $email,
                        '{prenom}' => $prenom,
                        '{nom}' => $nom,
                        '{tel}' => $tel,
                        '{ville}' => $ville,
                        '{numeroclient}' => $numeroclient,
                        '{lit}' => $lit,
                        '{long_lit}' => $largeur_lit,
                        '{panneaux}' => $panneaux,
                        '{coloris}' => $coloris,
                        '{couleur_lit}' => $couleur_lit,
                        '{pietement}' => $pietement,
                        '{releve}' => $releve,
                        '{lattes}' => $lattes,
                        '{barrieres}' => $barrieres,
                        '{potence}' => $potence
                    ),
                    Configuration::get('PS_SHOP_EMAIL'), // receiver email address
                    NULL, //receiver name
                    '*************', //from email address
                    NULL  //from name
                );

            } elseif ($lit == 2) {
                Mail::Send(
                    (int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id
                    'devis-lit', // email template file to be use
                    '*********************', // email subject
                    array(
                        '{email}' => $email,
                        '{prenom}' => $prenom,
                        '{nom}' => $nom,
                        '{tel}' => $tel,
                        '{lit}' => $lit,
                        '{long_lit}' => $largeur_lit,
                        '{panneaux}' => $panneaux,
                        '{coloris}' => $coloris,
                        '{couleur_lit}' => $couleur_lit,
                        '{pietement}' => $pietement,
                        '{releve_droite}' => $releve_droite,
                        '{releve_gauche}' => $releve_gauche,
                        '{lattes_droite}' => $lattes_droite,
                        '{lattes_gauche}' => $lattes_gauche,
                        '{barrieres}' => $barrieres,
                        '{potence}' => $potence
                    ),
                    $email, // receiver email address
                    NULL, //receiver name
                    '*******************', //from email address
                    NULL  //from name
                );

                Mail::Send(
                    (int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id
                    'devis-lit_2', // email template file to be use
                    ' Demande de devis en ligne via le configurateur 3D', // email subject
                    array(
                        '{email}' => $email,
                        '{prenom}' => $prenom,
                        '{nom}' => $nom,
                        '{tel}' => $tel,
                        '{ville}' => $ville,
                        '{numeroclient}' => $numeroclient,
                        '{lit}' => $lit,
                        '{long_lit}' => $largeur_lit,
                        '{panneaux}' => $panneaux,
                        '{coloris}' => $coloris,
                        '{couleur_lit}' => $couleur_lit,
                        '{pietement}' => $pietement,
                        '{releve_droite}' => $releve_droite,
                        '{releve_gauche}' => $releve_gauche,
                        '{lattes_droite}' => $lattes_droite,
                        '{lattes_gauche}' => $lattes_gauche,
                        '{barrieres}' => $barrieres,
                        '{potence}' => $potence
                    ),
                    Configuration::get('PS_SHOP_EMAIL'), // receiver email address
                    NULL, //receiver name
                    '*******************', //from email address
                    NULL  //from name
                );
            }
            return 'yes';
        } else {
            return 'Erreur, veuillez réessayer';
        }
    }

I don't understand why, please help me :(

 

Have a nice day !

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