? ? Pending

User tests: Successful: Unsuccessful:

avatar PhilETaylor
PhilETaylor
31 May 2021

Pull Request for Issue #34287

Summary of Changes

Allows the use of place holders in the custom file name of an attachment for mail templates.

Testing Instructions

Install a fresh Joomla 4 - set up your mail settings correctly and test them.

(Tip: Learn what MailHog is if you dont already use it!)

  • Login to Joomla Admin
  • System -> Mail Templates -> Options
  • set Attachment Folder = images
  • Save and close
  • System -> Mail Templates -> Edit Global Configuration: Test Mail
  • Click + to add a new file
  • Select joomla_blank.png
  • Type {METHOD}_test.png as the name of the file
  • Save and close
  • System -> Global Configuration -> Server Tab -> Test Mail button...
  • Check your mail.

Actual result BEFORE applying this Pull Request

{METHOD}_test.png would be the name of the file attached to your email

Expected result AFTER applying this Pull Request

{METHOD} will get replaced with your mail method (Mine is SMTP)

Mine therefore is SMTP_test.png when attached.

Screenshot 2021-05-31 at 22 38 49

Documentation Changes Required

None - its a secret.

Commentry

Thinking how this feature might be used, the 3pd might want to add dynamic detail to the file name. E.g Joe Blogs buys an ebook, and so the filename becomes Order123_Bloggs_book.pdf dynamically using the placeholders.

### Security

I cannot see a way that this can be used to spoof anything, happy to be proved wrong. The same checks on file extensions will still apply, and phpMailer restrictions on the files name will also apply still as they did before this PR.

avatar PhilETaylor PhilETaylor - open - 31 May 2021
avatar PhilETaylor PhilETaylor - change - 31 May 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 31 May 2021
Category Libraries
avatar PhilETaylor PhilETaylor - change - 31 May 2021
Title
Replace placeholders in file names
[4] Replace placeholders in file names of attachments in Mail Templates
avatar PhilETaylor PhilETaylor - edited - 31 May 2021
avatar PhilETaylor PhilETaylor - change - 31 May 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 31 May 2021
avatar PhilETaylor PhilETaylor - change - 31 May 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 31 May 2021
avatar PhilETaylor PhilETaylor - change - 31 May 2021
Labels Added: ?
avatar joomdonation
joomdonation - comment - 2 Jun 2021

This works, but honestly, I could not see a real use-case for this option.

avatar PhilETaylor
PhilETaylor - comment - 2 Jun 2021

then you obviously did not read what I wrote when I gave you one

Thinking how this feature might be used, the 3pd might want to add dynamic detail to the file name. E.g Joe Blogs buys an ebook, and so the filename becomes Order123_Bloggs_book.pdf dynamically using the placeholders.

Also can be used for translating filenames...

avatar joomdonation
joomdonation - comment - 2 Jun 2021

then you obviously did not read what I wrote when I gave you one

I read it. But I still don't see a real use case for this. It's my personal option. You can wait for feedback from others.

avatar PhilETaylor
PhilETaylor - comment - 2 Jun 2021

In Joomla CMS, no there is not currently a use case.

But Joomla is more than just its CMS. Its a framework for developers and 3pd also. There is no reason NOT to add this, especially when placeholders can be added to the rest of the mail (subject, body).

3pd are always pushing the boundaries of what Joomla does.

avatar joomdonation
joomdonation - comment - 2 Jun 2021

I'm a third party developer and I can tell you that I would not use tags in filename of attachment. Anyway, that's just my personal opinion (and I'm happy to not have to make decision :) ).

avatar brianteeman
brianteeman - comment - 2 Jun 2021

@joomdonation until yesterday I would have agreed with you but last night I came across a situation using an event registration system where it would have been really great

avatar joomdonation
joomdonation - comment - 2 Jun 2021

@brianteeman Thanks for the info.

avatar RickR2H
RickR2H - comment - 14 Jun 2021

@PhilETaylor I tried to add a file but in the nightly build clicking the "Plus" doesn't add a field or add an image selector. Is this a problem in the nightly build?

screen shot 2021-06-14 at 09 14 18


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/34321.
avatar PhilETaylor
PhilETaylor - comment - 14 Jun 2021

No idea - it certainly used to work, Check your Console tab for any errors.

avatar RickR2H
RickR2H - comment - 14 Jun 2021

Checkout the J! repo and got the same problem. Don't know if the error is related...
Image-4

avatar PhilETaylor
PhilETaylor - comment - 14 Jun 2021

That error is unrelated.

avatar joomdonation
joomdonation - comment - 14 Jun 2021

@RickR2H I can confirm the issue with nightly build. Could you please open an issue as it is unrelated to this PR?

avatar maikol-ortigueira maikol-ortigueira - test_item - 16 Jul 2021 - Tested successfully
avatar maikol-ortigueira
maikol-ortigueira - comment - 16 Jul 2021

I have tested this item successfully on 95d28f0

I have tested this issue with the two allowed placeholders (sitename & method), using Mailhog and it works successfully.
Joomla Version: 4.0.0-rc4
PHP Version: 7.4.13

One question, why is it not possible to use the lowercase placeholders?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/34321.

avatar pabloarias pabloarias - test_item - 16 Jul 2021 - Tested successfully
avatar pabloarias
pabloarias - comment - 16 Jul 2021

I have tested this item successfully on 95d28f0

Tested with Devilbox. PHP 7.4.

After applying the path and follow testing instructions the file attached name is Mail_test.png


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/34321.

avatar richard67 richard67 - change - 17 Jul 2021
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 17 Jul 2021

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/34321.

3584e26 21 Jul 2021 avatar wilsonge CS
avatar wilsonge wilsonge - change - 21 Jul 2021
Labels Added: ?
avatar wilsonge wilsonge - change - 21 Jul 2021
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-07-21 21:47:46
Closed_By wilsonge
avatar wilsonge wilsonge - close - 21 Jul 2021
avatar wilsonge wilsonge - merge - 21 Jul 2021
avatar wilsonge
wilsonge - comment - 21 Jul 2021

Thanks!

Add a Comment

Login with GitHub to post a comment