Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

wp_mail issues: recurrence of mail delivery and endless blank webpage loading

$
0
0

Replies: 0

Title: Massive recurrence of mail delivery and endless blank webpage loading
Greetings.
I wanted to build a simple feature that would deliver mail notification to the order owner(buyer) when there is an inequality between $ship_code and $old_code(provided $ship_code is not empty).
To develop that , I applied wp_mail() function in my code but it ended up with recurrence of mail delivery(At the point I write this message, there have been more than 300 mails received.) and the whole site keeps loading endlessly on blank page.
The code section written is provided as below. Could you assist me on this issue? Thank you.

———–code—————
add_action( ‘save_post’, [$this, ‘save_data_for_custome_data’],1,2);
public function save_data_for_custome_data($post_id){
if(isset($_POST[‘ship_code’])){
$ship_code = $_POST[‘ship_code’];
$old_code = get_post_meta($post_id,’ship_code’,true);
if($ship_code != $old_code && $ship_code !=”){
$subject = ‘test subject’;
$to = $_POST[‘_billing_email’];
$content = ‘Your ShipCode is’.$ship_code;
wp_mail( $to, $subject, $content );
}
update_post_meta($post_id, ‘ship_code’, $ship_code);
}
}

add_action( ‘save_post’, [$this, ‘save_data_for_custome_data’],1,2);
public function save_data_for_custome_data($post_id){
if(isset($_POST[‘ship_code’])){
$ship_code = $_POST[‘ship_code’];
$old_code = get_post_meta($post_id,’ship_code’,true);
if($ship_code != $old_code && $ship_code !=”){
$mailer = WC()->mailer();
$to = $_POST[‘_billing_email’];
$subject = ‘test subject’;
$content = ‘Your ShipCode is’.$ship_code;
$mailer->send( $to, $subject, $content );
}
update_post_meta($post_id, ‘ship_code’, $ship_code);
}
}

WC()->mailer() has same problem


Viewing all articles
Browse latest Browse all 59525

Trending Articles