Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress mails get sent text-only


  • fidelleon
    Participant

    @fidelleon

    WordPress 4.5.1
    BuddyPress 2.5.1
    Geodirectory framework and Geodirectory’s Modern theme.

    Buddypress mails get sent but only using the plain text version. I have modified one of the templates with different wording for HTML and plain text, and no matter what, the system always send the plain text version, so it seems like some part of the system is deciding to just take such version.

    My WordPress instance doesn’t have (and very likely won’t have) a local SMTP server so I’m using “Easy WP SMTP” to communicate with Google servers. I also use BP Registration Options to get account validations.

Viewing 9 replies - 1 through 9 (of 9 total)

  • fidelleon
    Participant

    @fidelleon

    From what I see, “something” is using post_excerpt instead of post_content but can’t find the code which decides which one to choose…


    fidelleon
    Participant

    @fidelleon

    … and I’ve been able to remove “Easy WP SMTP” since the machine actually had a local SMTP server. But still text-only.


    art386art
    Participant

    @art386art

    Yes! Easy WP SMTP plugin – Cool Plugin! Google SMTP Super!


    fidelleon
    Participant

    @fidelleon

    “Solution” told here works fine but requires modifying core:

    https://buddypress.org/support/topic/2-5-html-email-styling-not-working/

    The BP Registration Options plugin forces in some way to send the emails using content_plaintext instead of content_html:

    $must_use_wpmail = apply_filters( ‘bp_email_use_wp_mail’, $wp_html_emails || ! $is_default_wpmail );

    It gets set to true so:

    if ( $must_use_wpmail ) {

    […]
    $email->get( ‘content_plaintext’, ‘replace-tokens’ )

    If you visit the “Manage Signups” and send an email to the user (reminding to activate their accout), the mail is 100% HTML w/o touching anything…


    Bharat
    Participant

    @chavodbharat

    I have found solutions for html email text
    there is some changes in bp_core files :
    You can change content type given below path:
    \wp-content\plugins\buddypress\bp-core\bp-core-functions.php line number 2962

    put content_html text instead content_plaintext:
    content_plaintext should be send plain text email and content_html should be

    send html email:
    $email->get( ‘content_plaintext’, ‘replace-tokens’ )

    $email->get( ‘content_html’, ‘replace-tokens’ )

    I would like to give suggestions, if buddypress team should be given backend options like select content type (1)HTML email (2)Plain text
    because buddypress have not given any hook for changes content type text


    shanebp
    Moderator

    @shanebp

    You can open a ticket here. Use the same user name and password that you use for this forum.


    vbnr
    Participant

    @vbnr

    Hi,
    is not necessary to change system files.
    Look that code

    $wp_html_emails = apply_filters( 'wp_mail_content_type', 'text/plain' ) === 'text/html';

    So the right way is just to add filter who returns ‘text/html’

    add_filter('wp_mail_content_type', 'text/plain', function () {
        return 'text/html';
    });
    

    jackal
    Participant

    @anasmokayed

    Hi @vbnr!

    Would you explain a bit more! Where to add this filter? I tried to add it in \wp-content\plugins\buddypress\bp-core\bp-core-functions.php under the specific code but it doesn’t work!

    I even tried the previous solution to replace content_plaintext with content_html and yet users receive emails in plain text.

    Would you help me with this?


    alwaysalready
    Participant

    @alwaysalready

    I found a way to resolve this problem using a mixture of ideas, including the suggestions from @bharat and @vbnr. I’ve put the details in a blog post here. In summary, what worked for me was the following in the bp-custom.php file:

    // Set BP to use wp_mail
    add_filter( 'bp_email_use_wp_mail', '__return_true' );
     
    // Set messages to HTML
    remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
    add_filter( 'wp_mail_content_type', 'set_html_content_type' );
    function set_html_content_type() {
        return 'text/html';
    }
     
    // Use HTML template
    add_filter( 'bp_email_get_content_plaintext', 'get_bp_email_content_plaintext', 10, 4 );
    function get_bp_email_content_plaintext( $content = '', $property = 'content_plaintext', $transform = 'replace-tokens', $bp_email ) {
        if ( ! did_action( 'bp_send_email' ) ) {
            return $content;
        }
        return $bp_email->get_template( 'add-content' );
    }
     
    // Optionally change your email address and from name.
    add_filter('wp_mail_from','noreply_from');
    function noreply_from($from) {
      return 'noreply@YOUR_DOMAIN.org'; //Replace 'YOUR_DOMAIN.org' with email address
    }
     
    add_filter('wp_mail_from_name','noreply_from_name');
    function noreply_from_name($name) {
        return 'YOUR_DOMAIN No-Reply'; //Replace 'YOUR_DOMAIN No-Reply' with the from name
    }
Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar