[wp-trac] [WordPress Trac] #28059: Inline image attachments with wp_mail()

WordPress Trac noreply at wordpress.org
Sat Aug 30 13:39:09 UTC 2025


#28059: Inline image attachments with wp_mail()
-------------------------------------------------+-------------------------
 Reporter:  jesin                                |       Owner:  SirLouen
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  6.9
Component:  Mail                                 |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-test-info has-unit-    |     Focuses:
  tests add-to-field-guide                       |
-------------------------------------------------+-------------------------

Comment (by SirLouen):

 Replying to [comment:20 TimothyBlynJacobs]:
 > Looking at the example usages has really solidified the need to have
 predictable CID values. Since the path to the file is going to be dynamic,
 not being able to write the template value with a fixed CID means you have
 to do that interpolation you are showing in the example. I know there is a
 filter available, but needing to add and then remove a filter around your
 `wp_mail` call is awkward. A developer shouldn't need to use a filter to
 accomplish what looks like will be the common case.

 Ok, I see your point

 > Let's try a different signature where the `cid` value is the array key.
 I don't think we need to support the same new line parsing, or array
 conversion that we do for the `headers` parameter for instance.

 Yes, this simplifies a lot the CID generation. To be sincere, I opted into
 the safe side because it seems that in the MIME `cid` "literature", using
 MD5 is a popular practice. Technically, this approach should not cause
 collisions, but it looks so simple that there could be an edge case I
 can't think of. Although, logically, it feels safe.

 Anyway, I've adapted everything to this simpler `cid` version because it
 looks better.

 This is the updated version of [https://raw.githubusercontent.com/SirLouen
 /wp-mail-embed-showcase/refs/tags/1.0.1/wp-mail-embed-showcase.php my
 testing plugin]

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


More information about the wp-trac mailing list