awesomemotive / wp-mail-logging

:envelope: Logs each email sent by WordPress.
48 stars 25 forks source link

UTF8 encoded subjects #162

Closed donmhico closed 1 year ago

donmhico commented 1 year ago

Description

This PR adds the ability to support UTF8-encoded subjects in the email logs table

Testing Procedure

  1. Submit an email using wp_mail() with subject containing non ASCII characters. You can use the snippet below.

    add_action( 'init', function () {
    $to      = 'donmhico+test1@gmail.com';
    $subject = 'Subject with non ASCII ó¿¡á';
    $message = 'Message with non ASCII ó¿¡á';
    $headers = 'From: example@example.com'."\r\n"
    .'Content-Type: text/plain; charset=utf-8'."\r\n";
    
    wp_mail(
        $to,
        '=?utf-8?B?'. base64_encode( $subject ) . '?=',
        $message,
        $headers
    );
    } );
  2. Check WP Mail Logging's Email Logs. You should see the subject displaying properly.
Screen Shot 2023-05-04 at 17 17 51

If you see the log details, you should also see this in HTML tab.

Screen Shot 2023-05-04 at 17 19 29

However, you should see the actual encoded subject in both RAW and JSON tab.