• Why wordpress mail sending twice email? Also tried php mail and it sending still twice.

    $to = "[email protected]";
    $headers = "Reply-To: myemail <[email protected]>\r\n"; 
    $headers .= "Return-Path: myemail <[email protected]>\r\n"; 
    $headers .= "From: [email protected]" ."\r\n";
    $headers .= "Organization: myemail.com\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=utf-8\r\n";
    $headers .= "X-Priority: 3\r\n";
    $headers .= "X-Mailer: PHP". phpversion() ."\r\n" ;
    wp_mail( $to, $subject, $content, $headers );
    
    $admin_email = "[email protected]";
    $subject2 = 'Osteti uus parkla pilet!';
    $headers2 = "Reply-To: myemail <[email protected]>\r\n"; 
    $headers2 .= "Return-Path: myemail <[email protected]>\r\n"; 
    $headers2 .= "From: [email protected]" ."\r\n";
    $headers2 .= "Organization: myemail.com\r\n";
    $headers2 .= "MIME-Version: 1.0\r\n";
    $headers2 .= "Content-type: text/html; charset=utf-8\r\n";
    $headers2 .= "X-Priority: 3\r\n";
    $headers2 .= "X-Mailer: PHP". phpversion() ."\r\n" ;

    wp_mail($admin_email, $subject2, $content2, $headers2)
    Im sending one email for customer if successful payment and second to site admin if there was succesful payment

    I dont use any loop. Only fetching single customer email.

Viewing 2 replies - 1 through 2 (of 2 total)
  • So from your description, you have determined that your code that sends the email is being called twice. What is triggering your code? Is it a webhook to notify payment?

    I would recommend setting xdebug up with an IDE, if you don’t have that already and stepping through the execution.

    Without the full code, that is about all I can suggest.

    Moderator bcworkz

    (@bcworkz)

    I think Alan is on to something regarding webhooks. Many hooks unexpectedly fire more than once per request. In typical usage, the redundancy doesn’t matter. When it does matter, have your hook callback remove itself from the call stack after the first pass through so it no longer executes on subsequent hook firings.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress mail sending twice’ is closed to new replies.