WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#30128 new enhancement

Allow to use associative arrays beside indexed arrays in wp_mail $headers

Reported by: marsjaninzmarsa Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.3
Component: Mail Keywords: has-patch needs-testing needs-codex needs-unit-tests
Focuses: Cc:

Description

eg:

$headers = [
	'From' => 'Me Myself <me@example.net>',
	'Cc'   => 'John Q Codex <jqc@wordpress.org>',
];

beside:

$headers = [
	'From: Me Myself <me@example.net>',
	'Cc: John Q Codex <jqc@wordpress.org>',
];

and also (because why not):

$headers = [
	'From' => 'Me Myself <me@example.net>',
	'Cc'   => [
		'John Q Codex <jqc@wordpress.org>',
		'iluvwp@wordpress.org',
	],
];

Attachments (3)

30128.path (1.9 KB) - added by marsjaninzmarsa 4 years ago.
30128.patch (1.9 KB) - added by marsjaninzmarsa 3 years ago.
fixes (typo in previous filename)
30128.2.patch (1.6 KB) - added by jorbin 3 years ago.

Download all attachments as: .zip

Change History (8)

#1 @marsjaninzmarsa
4 years ago

  • Keywords has-patch needs-testing needs-codex added

This ticket was mentioned in IRC in #wordpress-dev by marsjaninzmarsa. View the logs.


4 years ago

#3 @marsjaninzmarsa
4 years ago

It is also possible to use single line notation for multiple CC/BCC, eg:

$headers = [
	'From: Me Myself <me@example.net>',
	'Cc: Fo McFoo <foo@example.com>, bar@example.com',
];

@marsjaninzmarsa
3 years ago

fixes (typo in previous filename)

#4 @boonebgorges
3 years ago

  • Version changed from trunk to 2.3

@jorbin
3 years ago

#5 @jorbin
3 years ago

  • Keywords needs-unit-tests added

This looks like a good idea. It could use some unit tests though to be on the safe side. The current mail unit tests pass.

I've refreshed the patch above so that it applies cleanly.

Note: See TracTickets for help on using tickets.