Skip to:

Opened 3 years ago

Last modified 3 years ago

#8104 new enhancement

add filter in bp_send_email to allow html email in wp_mail call

Reported by: shawfactor Owned by: DJPaul
Milestone: Awaiting Contributions Priority: normal
Severity: normal Version: 4.3.0
Component: Emails Keywords: reporter-feedback


Currently when you need to use wp_mail in the bp_send_email function the content sent is plain text. As far as I can see there is not way to override this.

I understand why this is the default but this causes a problem if you have downstream filters on wp_mail and expect or want the output to be in html format. For instance in my case I have html queue class that logs all emails and sends them asynchronously.

Unfortunately if I want to use this class the emails must be plain text, which is not what I want as I have another downstream process that actually makes all emails multipart anyway.

This problem could be fixed by simply adding a filter on bp-core-functions.php line 3201 thus:

$email->get( apply_filters( 'bp_email_content_type', 'content_plaintext' ), 'replace-tokens' )

I really hope something like this could be added to the core plugin

Change History (2)

#1 @imath
3 years ago

  • Component changed from Core to Emails
  • Keywords reporter-feedback added; needs-patch removed
  • Owner set to DJPaul

Hi @shawfactor

I think you can already filter the content to be HTML. Could you try to use the filter bp_email_get_content_plaintext like what I've wrote into this gist?

#2 @imath
3 years ago

  • Milestone changed from Awaiting Review to Awaiting Contributions

I think we need time to work on this need. From what I understand so far:

If the plain text is used although wp_mail content type is filtered to be text/html is probably due to the fact some plugins might use their own template (header/footer) and forcing ours might be a problem.

I also think only sending html e-mails can be problematic for receivers who set their mail software to only accept plain text. BP e-mails are including an alternate text version of the html e-mail for this case. I don’t see right now how we can/ if we need to check if the use made with wp_mail contains this alternate version (I know it’s possible).

Let’s wait for contributions by the community or other members of the dev team.

Note: See TracTickets for help on using tickets.