Br not working in wp_mail

The br tag not working in wp_mail can be a frustrating issue!

The wp_mail function in WordPress uses the wp_mail_content_type filter to determine the content type of the email. By default, this filter is set to text/plain, which means that any HTML tags, including br, will be stripped from the email content.

To fix this issue, you can try one of the following solutions:

  1. Use the wp_mail_content_type filter: You can use the wp_mail_content_type filter to set the content type to text/html, which will allow HTML tags, including br, to be rendered in the email. You can do this by adding the following code to your theme's functions.php file:
    function set_wp_mail_content_type_to_html($content_type) {
     return 'text/html';
    }
    add_filter('wp_mail_content_type', 'set_wp_mail_content_type_to_html');
  2. Use the wp_mail_charset filter: Another option is to use the wp_mail_charset filter to set the charset of the email to a value that supports HTML entities, such as UTF-8. You can do this by adding the following code to your theme's functions.php file:
    function set_wp_mail_charset_to_utf8($charset) {
     return 'UTF-8';
    }
    add_filter('wp_mail_charset', 'set_wp_mail_charset_to_utf8');
  3. Use the wp_mail function with the format parameter: You can also use the wp_mail function with the format parameter set to HTML. This will allow you to send HTML emails with br tags intact. For example:
    wp_mail($to, $subject, $message, 'Content-Type: text/html; charset=UTF-8');

    Note that the format parameter is only available in WordPress 4.4 and later versions.

I hope one of these solutions works for you!