Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: wp_mail() sending twice

Discussion in 'Misc WordPress Requests' started by Dipak C. Gajjar, Jan 18, 2018.

  1. Dipak C. Gajjar

    Guest

    Reply To: wp_mail() sending twice, by Dipak C. Gajjar

    Could you try the following code?

    <?php
    session_start();
    $nom = isset($_SESSION['nom']) ? $_SESSION['nom'] : '';

    require_once('Mercanet.php');

    // Initialisation de la classe Mercanet avec passage en parametre de la cle secrete
    $paymentResponse = new Mercanet('002001000000001_KEY1');
    $paymentResponse->setResponse($_POST);
    ?>

    <?php $mts_options = get_option(MTS_THEME_NAME); ?>
    <?php get_header(); ?>
    <div id="page" class="single">
    <div class="container">
    <article class="<?php mts_article_class(); ?>">
    <div id="content_box" class="panel">
    <?php
    if($paymentResponse->isValid() && $paymentResponse->isSuccessful()){
    // Traitement pour les paiements valides
    echo "paiement reussi ";
    $emailTo = '[email protected]';
    $subject = 'Paiement de la facture';
    /*$sendCopy = trim($_POST['sendCopy']);*/
    $body = "paiement accepté $nom";
    $headers .= "Content-Type: text/plain; charset=UTF-8\n";
    $headers .= "Content-Transfer-Encoding: 8bit\n";
    }
    else{
    // Traitement pour les paiements en echec
    echo "paiement en echec ";
    $emailTo = '[email protected]';
    $subject = 'Paiement de la facture';
    /*$sendCopy = trim($_POST['sendCopy']);*/
    $body = "paiement echec $nom";
    $headers .= "Content-Type: text/plain; charset=UTF-8\n";
    $headers .= "Content-Transfer-Encoding: 8bit\n";
    }
    if (is_page() && $nom != '') {
    wp_mail($emailTo, $subject, $body, $headers);
    }
    ?>
    </div>
    </article>
    </div>
    </div>

    <?php get_footer();
    session_destroy();
    ?>

    Hopefully, this should send a single email only.

    Reply To: wp_mail() sending twice
     
    #1

Share This Page

Monarch Social Sharing Plugin