@shanebp That’s interesting. “Could not instantiate mail function” error comes from PHPMailer which (most likely) happens if the PHP mail
call fails.
Is PHP Safe Mode enabled?
Is PHP Safe Mode enabled?
No, afaik.
Host is running php 5.4 in which, I believe, safe_mode was removed.
@shanebp Can you replace bp-email-debug.php
with https://www.dropbox.com/s/yz1155axhbyntw7/bp-email-debug-2.php?dl=0 and run again?
It dumps the Email object along with the error message, so I can test some ideas.
Can I also get the URL of the site this is being tested on?
Thanks!
I had to tweak your bp-email-debug-2.php
so that the $email
object is not overwritten.
function pg_bp25_email_debug_failure( $status, $email ) {
$email_admin = bp_get_option( 'admin_email' );
if ( is_wp_error( $status ) ) {
$message = $status->get_error_message() . PHP_EOL . PHP_EOL . print_r( $email, true );
} else {
$message = 'Failure but not WP_Error.';
}
wp_mail( $email_admin, 'BuddyPress 2.5 email -- debug', $message );
}
I’ve sent you an email with the$email
object.
Hi, i’ve a working solution for those like me who did not receive any buddypress email with html format (because there was a 3rd party plugin which was redeclaring wp_mail for eg.), here is the code to put in your functions.php file in your theme :
/**
* Provide an HTML template for all your BuddyPress emails
* BuddyPress 2.5 introduced a new stylised HTML email system.
* By default the HTML system doesn't work if a 3rd party transactional email plugin is active
* (e.g. wpMandrill or SendGrid), and reverts to sending plain text emails.
*
* This function allows the stylised BuddyPress HTML emails to be sent using some 3rd party plugin.
* It does this by sending the email through wp_mail() rather than directly with PHPMailer.
*
* @author Mecanographik
*
* inspiration :
* @link https://github.com/21applications/bp-wpmandrill
*
*/
add_action( 'init', 'my_prefix_bp_wp_mail_html_filters' );
function my_prefix_bp_wp_mail_html_filters() {
add_filter( 'bp_email_use_wp_mail', function( $bool ) {
return false;
}, 10, 1 );
}
hope this helps 😉
Note about the previous snippet :
If html still doesn’t work, just add this second (and complementary) function in functions.php :
/*
* Force HTML content type format for wp_mail
*/
function set_content_type( $content_type ){
if( empty($content_type) OR $content_type == 'text/plain' ) {
$content_type = 'text/html';
}
return $content_type;
}
add_filter( 'wp_mail_content_type', 'set_content_type', 1 );
Did it help you?
Was stuck on this for a couple of days, so much trouble shooting. I had set up the Buddypress fancy HTML email and it was all working fine, then a few days later, did a test and it had defaulted to plain text, out of no where.
Thanks mecanographik!
Your first post above worked a charm.