How to stop the wp_mail function?

I’m using wp_mail filter function. add_filter(‘wp_mail’,’check_the_mail_content’); If my condition satisfied then the mail should go, otherwise I need to stop, my function is add_filter(‘wp_mail’,’check_the_mail_content’); function check_the_mail_content($query){ if(mycondition){ //mail should go. } else{ //stop the mail. } } 6 Answers 6 Filter ‘phpmailer_init’, not ‘wp_mail’. To prevent sending the mail out reset the PHPMailer object. Prototype … Read more

wp_mail very slow

I have a question about the wp_mail() function. Right now I’m having the following button to send e-mail with: echo ‘<input type=”submit” name=”send_button” value=”verzenden” id=”‘.$post_id.'” class=”send_post”>’; which triggers a jQuery request: jQuery(document).ready(function() { jQuery(“.send_post”).click(function() { var post_id = $(this).attr(‘id’); jQuery.ajax({ async: false, type: ‘get’, url: nieuwsbrief.sendmail_url, data: ‘postid=’ + post_id, success: function(data) { alert(data); return … Read more

wp_mail isn’t making the from header correctly

So I’ve got a couple of different plugins which I’m attempting to change the from address of the email header. I’ve tried using the filters, but it’s simply sending the email as the admin user account on the site. add_filter( ‘wp_mail_from_name’, ‘my_mail_from_name’ ); function my_mail_from_name( $name ) { return “My Name”; } add_filter( ‘wp_mail_from’, ‘my_mail_from’ … Read more

How to email user after inserting the username in database in WordPress

I have following piece of code, which inserts usernames and other details of users in the database. After inserting the usernames I want to email them using wp_mail();. I am unable to do so. How can I do this? $member_details->user_login = array_map( ‘sanitize_text_field’, $_POST[‘user_login’] ); $member_details->user_role = array_map( ‘sanitize_text_field’, $_POST[‘user_role’] ); $member_details->status = array_map( ‘sanitize_text_field’, … Read more

Unexpected = (equal sign) characters in wp mail

I have created a custom form for user registration and a custom html email when someone registers. $headers=”From: test<[email protected]>” . “\r\n”; $subject=”Test Subj”; $msg=”; $msg .= ‘ATTN: ‘.$fname.'<br><br>’; $msg .= ‘<strong>*Please confirm receipt of this message. If you are not the intended recipient, please notify us immediately.*</strong><br><br>’; $msg .= ‘The * is delighted to invite … Read more