[wp-trac] [WordPress Trac] #28407: You are unable to override the attachment name in wp_mail() when adding attachments

WordPress Trac noreply at wordpress.org
Thu Dec 28 11:58:29 UTC 2017


#28407: You are unable to override the attachment name in wp_mail() when adding
attachments
--------------------------------------+--------------------
 Reporter:  syntaxart                 |       Owner:
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  5.0
Component:  Mail                      |     Version:  3.9.1
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+--------------------
Changes (by swissspidy):

 * keywords:  has-patch needs-unit-tests => has-patch has-unit-tests
 * milestone:  Future Release => 5.0


Comment:

 I just uploaded [attachment:28407.2.diff] as a refreshed patch of the
 original idea, along with unit tests.

 While I was at it, I also created [attachment:28407-alternative.diff],
 which would allow developers to override every argument for an attachment.
 An example from the unit test:

 {{{#!php
 wp_mail( 'user at example.org', 'Subject', 'Hello World', '', array(
         array(
                 'path' => DIR_TESTDATA . '/images/canola.jpg',
                 'name' => 'myawesomeimage.jpg',
                 'encoding' => '8bit',
                 'type' => 'image/jpeg',
                 'disposition' => 'attachment',
         ),
         array(
                 'path' => DIR_TESTDATA . '/images/waffles.jpg',
                 'name' => 'foobar.jpg',
                 'encoding' => 'base64',
                 'type' => 'image/png',
                 'disposition' => 'inline',
         ),
 ) );
 }}}

 I'm not 100% this is a good idea, since it makes it very easy to mess
 something up. But it would certainly be more future-proof than using an
 associative array.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28407#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list