WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 10 months ago

#30204 closed defect (bug) (reported-upstream)

wp_mail() bug with UTF-8-named attachment

Reported by: Blue Liquid Designs Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Mail Keywords:
Focuses: Cc:

Description

Hi,

I came across a problem with phpmailer when attaching UTF-8 encoded files to the email. The file is correctly sent but the attached filename is incorrect.

For instance, Τεστ1_Τεστ2.pdf becomes 1_Τεστ2.pdf.

I tracked it down to line 1984 of /wp-includes/class-phpmailer.php, which is

$filename = basename($path);

From the research I did, unless the correct locale has been set using setlocale() before running basename() problems like this will occur.

The simple solution would be to run setlocale() for the correct language before sending mail, but it's not possible to determine the correct locale if you have users who write in multiple languages using the website.

Since WordPress has been pushing internationalisation hard in the last few updates this seems like another good step forward to support multi-languages.

Change History (3)

#1 @johnbillion
7 years ago

  • Component changed from Mail to External Libraries

Thanks for the report.

This needs to be reported upstream to PHPMailer: https://github.com/PHPMailer/PHPMailer/issues

#2 @johnbillion
7 years ago

  • Version trunk deleted

#3 @desrosj
10 months ago

  • Component changed from External Libraries to Mail
  • Resolution set to reported-upstream
  • Status changed from new to closed

Because this is an issue in PHPMailer and requires an issue on their repository, I am going to close this out as reported-upstream.

Worth noting, PHPMailer has received some significant updates since this ticket was opened. The most recent version of PHPMailer was merged into WP Core in [48033] for version 5.5. It's possible that this issue was resolved with that update.

Note: See TracTickets for help on using tickets.