| | 310 | |
| | 311 | /** |
| | 312 | * @ticket 21659 |
| | 313 | */ |
| | 314 | public function test_wp_mail_addresses_arent_encoded() { |
| | 315 | $to = 'Lukáš To <to@example.org>'; |
| | 316 | $subject = 'Testing #21659'; |
| | 317 | $message = 'Only the name should be encoded, not the address.'; |
| | 318 | |
| | 319 | $headers = array( |
| | 320 | 'From' => 'From: Lukáš From <from@example.org>', |
| | 321 | 'Cc' => 'Cc: Lukáš CC <cc@example.org>', |
| | 322 | 'Bcc' => 'Bcc: Lukáš BCC <bcc@example.org>', |
| | 323 | 'Reply-To' => 'Reply-To: Lukáš Reply-To <reply_to@example.org>', |
| | 324 | ); |
| | 325 | |
| | 326 | $expected = array( |
| | 327 | 'To' => 'To: =?UTF-8?B?THVrw6HFoSBUbw==?= <to@example.org>', |
| | 328 | 'From' => 'From: =?UTF-8?Q?Luk=C3=A1=C5=A1_From?= <from@example.org>', |
| | 329 | 'Cc' => 'Cc: =?UTF-8?B?THVrw6HFoSBDQw==?= <cc@example.org>', |
| | 330 | 'Bcc' => 'Bcc: =?UTF-8?B?THVrw6HFoSBCQ0M=?= <bcc@example.org>', |
| | 331 | 'Reply-To' => 'Reply-To: =?UTF-8?Q?Luk=C3=A1=C5=A1_Reply-To?= <reply_to@example.org>', |
| | 332 | ); |
| | 333 | |
| | 334 | wp_mail( $to, $subject, $message, array_values( $headers ) ); |
| | 335 | |
| | 336 | /** @var MockPHPMailer $mailer */ |
| | 337 | $mailer = tests_retrieve_phpmailer_instance(); |
| | 338 | $sent_headers = preg_split( "/\r\n|\n|\r/", $mailer->get_sent()->header ); |
| | 339 | $headers['To'] = "To: $to"; |
| | 340 | |
| | 341 | foreach ( $headers as $header => $value ) { |
| | 342 | $target_headers = preg_grep( "/^$header:/", $sent_headers ); |
| | 343 | $this->assertEquals( $expected[ $header ], array_pop( $target_headers ) ); |
| | 344 | } |
| | 345 | } |