two-factor icon indicating copy to clipboard operation
two-factor copied to clipboard

Added a filter to override the email headers

Open talhaimam opened this issue 4 years ago • 2 comments

Hello, The email message was always sent in a text/plain format by default. The email messages containing the security code were absolutely minimal. I've added a filter to allow editing the email headers, so that the email content can also be rendered in other formats such as text/html. Furthermore, the to, cc and bcc addresses can be also be altered by adding these values to the header array using this filter.

I've tested this filter across different settings and environments, working nicely. Please review!

The plugin also had other filters which were not listed in the readme file, I've gone ahead and listed them there.

talhaimam avatar Oct 15 '21 15:10 talhaimam

Per yesterday's bug scrub, @georgestephanis would rather see a change to the email code to also send multipart text/html (which WP Core likely does) but is otherwise fine with this change in theory.

jeffpaul avatar Mar 24 '22 18:03 jeffpaul

@jeffpaul Makes more sense, let me look into it.

talhaimam avatar Mar 24 '22 19:03 talhaimam

@jeffpaul Getting back to this, the 2fa codes are sent using the wp_mail function, which sends the email in text/plain format by default. The wp_mail function does have in-built filters to change the email headers. So yes the core does have the capability to send multipart text/html, but it needs to be specified. Do you suggest altering the wp_mail function to send email in multipart text/html format by default? Or specifying the headers when using the wp_mail function in 2fa code?

talhaimam avatar Sep 20 '22 14:09 talhaimam

@talhaimam I think having this plugin default to multipart text/html by default makes sense, yes

jeffpaul avatar Sep 20 '22 14:09 jeffpaul

@jeffpaul one more thing, multipart/mixed or multipart/alternative mime-types require MIME encoding in the email content. If we set the default type to multipart, then the plugin's default message would need to be changed as well. Plugin Documentation would also need to mention that anyone editing the default email content, would need to make sure that the mime encoding is included. Setting it to send text/html though, wouldnt require any of this.

talhaimam avatar Sep 20 '22 15:09 talhaimam