New answers tagged

0

f you're using anything that allows you to configure SMTP within WordPress, take it out. Then put everything into a function: add_action('init','delay_until_init'); function delay_until_init(){ // call wp_mail() here }


0

Finally I figured out the cause and solution to my problem above. When I trying to send email in sub domain say http://test1.example.com, without custom From email address in header, the wp_mail() function itself sets the From email as support@test1.example.com which is invalid and hence the email was not sent. So to solve this, myself added a custom From ...


0

I run into the same issue and after a research, I found out that this is a bug with class-phpmailer.php. The bug was apparently introduced in WP 4.3.2. Even if the changelog doesn't mention it, the file was modified. Only reverting wp-includes/class-phpmailer.php to the version that was included in WP 4.3.1 fixed the issue. The class itself also has a ...


1

//dont work for me: $phpmailer = new stdClass; //for stop wp_mail function use: function my_action( $phpmailer ) { if( condition ) { $phpmailer->ClearAllRecipients(); } } add_action( 'phpmailer_init', 'my_action' );


1

phpmailer_init will always fire for every wp_mail() call - however, you can hook/unhook it conditionally like so: function wpse_224496_phpmailer_init( $phpmailer ) { // SMTP setup // Always remove self at the end remove_action( 'phpmailer_init', __function__ ); } function wpse_224496_wp_mail( $mail ) { // Example: only SMTP for emails ...



Top 50 recent answers are included