Hi, we’ve recently enabled the 2FA feature. Unfortunately the 2FA emails are very hard to read as there’s no formatting. I was wondering if this was intentional since finding the auth code is quite a challenge.
Thank you!
Hi, we’ve recently enabled the 2FA feature. Unfortunately the 2FA emails are very hard to read as there’s no formatting. I was wondering if this was intentional since finding the auth code is quite a challenge.
Thank you!
Hi! For better compatibility WP Cerber sends 2FA emails in plain text format, where lines are separated by the \n
(new line) symbol. It looks like you have an SMTP plugin and this plugin converts text emails into HTML format and ignores the \n
symbols instead of replacing them with <br/>
tags for proper line breaks. To fix this, the plugin should handle the new line symbols correctly when converting text emails to HTML.
Hi Gary, thanks for your help. It has pointed me in the right direction. We actually had the content type set to text/html for all emails. Removing this fixed the formatting problem.
add_filter('wp_mail_content_type', function($content_type) {
return 'text/html';
});
Alternatively, you can keep using HTML, but replace all new lines in the outgoing emails:
add_filter( 'wp_mail', function ( $args ) {
if ( isset( $args['message'] ) ) {
$args['message'] = nl2br( $args['message'] );
}
return $args;
} );