wp_mail() sending twice
-
Hi there,
I’m actually coding a page with a mail sending.
It’s a destination page for users after a payement with bank portal.
I need to send an email to the admin as a confirmation that the payment is achieved or not. But for now, the mail is sent two times. Here’s the code of the page :<?php session_start(); $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()) { wp_mail($emailTo, $subject, $body, $headers); } ?> </div> </article> </div> </div> <?php get_footer(); session_destroy(); ?>
The body of the mail is “paiement echec $nom”. One mail is getting the $nom variable stocked in the session but not the other.
If you have some clues it’ll be great.
Thanks !
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘wp_mail() sending twice’ is closed to new replies.