[wp-trac] [WordPress Trac] #19847: wp_mail $from_name field is removing an extra character from the name
WordPress Trac
noreply at wordpress.org
Mon Jul 11 19:18:03 UTC 2022
#19847: wp_mail $from_name field is removing an extra character from the name
---------------------------------------------------+---------------------
Reporter: hakanca | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.1
Component: Mail | Version: 3.3
Severity: normal | Resolution:
Keywords: has-patch dev-feedback has-unit-tests | Focuses:
---------------------------------------------------+---------------------
Changes (by desrosj):
* milestone: => 6.1
Comment:
Found this one while looking through the list of tickets missing a
milestone.
I wrote a unit test with a few assertions to confirm that this is still
happening, and looks like it is.
I've created a PR that includes both [attachment:"19847.2.diff"] and the
unit test, and looks like it does the trick. The `-1` is not actually
required anyway since the `trim()` call in the following lines will also
remove the space (if present).
Looking at how the headers are passed to PHPMailer, each one is expanded
using `explode()` before performing some basic trimming and adjusting to
be in the proper format before getting passed. For the from name and from
email, `setFrom()` within PHPMailer expects them to be passed as separate
parameters in order to perform some of its own validation.
With this in mind, we could add a `__doing_it_wrong()`, but I'm not sure
it's really necessary since PHPMailer will reconstruct the header
correctly with the space later on.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/19847#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list