Skip to:
Content
Pages
Categories
Search
Top
Bottom

Solved – BuddyPress Smtp Settings


  • drstrats
    Participant

    @drstrats

    Hi
    I’m using BuddyPress and upon registration of users, the email notifications are sent using the hosting server which lands 100% of the times at spam folder.
    to solve this I’ve installed the WP Mail SMTP plugin but this it didn’t affect BuddyPress Smtp settings.
    Please someone with a solution to solve this.
    Thanks

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

  • vapvarun
    Participant

    @vapvarun

    Try mailgun, easy to set up and the free plan will be enough.


    drstrats
    Participant

    @drstrats

    @vapvarun thanks for your reply

    Try mailgun, easy to set up and the free plan will be enough.

    but I’m not talking about how to setup wp mail plugin because I’ve already done that.
    the problem is BuddyPress still uses the hosting server to send emails and it ignores the wp mail configuration.


    vapvarun
    Participant

    @vapvarun

    okay got it, you can add following codes inside
    bp-custom.php or child theme functions.php to override
    add_filter('bp_email_use_wp_mail', '__return_true');


    vapvarun
    Participant

    @vapvarun


    drstrats
    Participant

    @drstrats

    I couldn’t find the bp-custom.php file so, I did add it to the bp-core-functions.php file then I test to send an email through BuddyPress. It was successfully delivered by the WP mail configurations but now another problem appeared, the email delivered in plain text format showing all the Html code as plain text.


    SirLouen
    Participant

    @sirlouen

    I can confirm that this is still an issue: if forcing wp_mail , buddypress mails can’t be HTML.

    Not sure why buddypress never switched to wp_mail which is the wp standard.


    alwaysalready
    Participant

    @alwaysalready

    I found a way to resolve this problem using a mixture of ideas others have shared elsewhere. 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 remove the filter above after it's run
    remove_filter('wp_mail','redirect_mails',20);
     
    // Optionally change your email address
    add_filter('wp_mail_from','noreply_from');
    function noreply_from($from) {
      return 'noreply@YOUR_DOMAIN.org'; //Replace 'YOUR_DOMAIN.org' with email address
    }
    
    // Optionally change your from name
    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
    }

    shanebp
    Moderator

    @shanebp

    @alwaysalready – thanks for posting your solution.
    Perhaps you could convert your blog article into a page in the codex.


    nqui
    Participant

    @nqui

    @alwaysalready Thank you so much!!!!!
    Your solution sorted everything. I so appreciate it!!!!!!!!!!!!!!!

    In case it is interesting to anyone, to try fix this before coming to this thread, I:
    1. installed “Check Email” to see if there was a problem sending emails from my site (there wasn’t)
    2. installed “WP Mail SMTP”, setting up SMTP with all its complications in case it was some sort of spam issue (it wasn’t)
    3. discovered using the above that the registration emails were being bounced with the error message “Diagnostic-Code: smtp; 550 Messages should have one or no To headers, not 2.” When I looked at the headers, sure enough, there were two “To: destination-email-address” lines in the header.
    4. Deactivated BuddyPress. Found that registration emails successfully went through.
    5. Finally came here, having found out that BuddyPress was definitely the culprit.

    All this has been quite stressful, it is the first website I’ve ever set up.


    coolhunt
    Participant

    @coolhunt

    @alwaysalready WOW.. Great stuff! Great Work!
    Your blog post on the issue and fix was very well written!
    Im trolling thru your blog now to pick up a few more tips and tricks 😀


    alwaysalready
    Participant

    @alwaysalready

    Thank you @nqui and @coolhunt. Glad it’s been helpful. @shanebp, I’ll look into adding it to the codex. Thank you for the suggestion.

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.
Skip to toolbar