Open thxred opened 5 years ago
True I can confirm it
Yes, seems like there are three possible properties here: field
, fieldvalue
and file
.
And I can see it's not respecting the custom folders, that's correct. I'll include a fix for this in an upcoming release. Thanks @thxred - and @nelsondcosta23!
Doc page to update: https://docs.formtools.org/modules/swift_mailer/file_attachments/
k, I'm going to bump this from 3.0.19 because it's taking a little long to resolve and that version has an important fix that needs to get out. I'll do another release this week to address this.
works with {$attachment fieldvalue="file_field1"}, and not {$attachment field="file_field1"} as stated in the documentation.
Both of these actually works fine for me. The fieldvalue
option is an older option which I didn't want advertised - I was planning on removing it eventually, but it stuck around.
More than 1 file using {$attachment fieldvalue="file_field1"} swiftmailer/template doesn't attach.
Hmm, confirmed!
Also doesn't respect the upload directory settings.
Confirmed. Thanks again @thxred! I'll get a new version out this weekend that patches these issues.
No, thank you Benkeen. I'm glad I could help! I have also implemented FPDF/QRCODE in the e-mail template. If I can be of any assistance in that regard to someone please let me know.
Okay, now I'm baffled haha! I swear I thought it was working with fieldvalue
but now I've been digging deeper today it's actually all working perfectly - and fieldvalue isn't working, which is correct... peculiar I thought it worked before; I think my manual testing must have been incorrect and I was mistaking what emails I was receiving from which test configuration.
Here's what I found. In all cases, multiple files are being attached properly - even when using combinations of the attachment types.
{$attachment field="fieldname1"}
This is the standard way to attach files. You just enter the field name of the file field and if that field has a file in it, it's included in the email. This does take into account custom file upload folders for each field.
{$attachment file="path/to/customfile.png"}
This is a way to include a specific file from your server in the email. You have to enter a path relative to the Form Tools root folder.
So far this is all correct & consistent with what's in the doc, but then there's a hidden third option that you uncovered (nice work)...
{$attachment fieldvalue="VARNAMEHERE"}
This is a puzzler! First it's puzzling that it's working for you by just passing in the field name, second that it looked like it worked for me, and third, what on earth I used this for! I suspect I must have had a custom requirement from a client at some point and added this in to solve my problem.
So I was mistaken before, this isn't legacy code. What this one does is look at VARNAMEHERE
and treat that as a Smarty variable, then convert that into a string, factoring in all the submission placeholders at its disposal. The submission placeholders are a bunch of info about the current form submission, like this:
...
[FILEURL_file_field2] => http://localhost:8888/core/dist/upload/silverbroadbill.jpg
[FOLDERURL_file_field2] => http://localhost:8888/core/dist/upload
[QUESTION_field3] => Field 3
[ANSWER_field3] =>
[QUESTION_field4] => Field 4
[ANSWER_field4] =>
[QUESTION_field5] => Field 5
[ANSWER_field5] =>
[ANSWER_core__submission_date] => 2019-10-17 3:39 AM
[SUBMISSIONDATE] => 2019-10-17 3:39 AM
[ANSWER_core__last_modified] => 2019-10-18 5:06 AM
[LASTMODIFIEDDATE] => 2019-10-18 5:06 AM
[ANSWER_core__ip_address] => ::1
[IPADDRESS] => ::1
[ADMINEMAIL] => ben.keen@gmail.com
[FORMNAME] => Test
[FORMURL] =>
[SUBMISSIONID] => 1
[LOGINURL] => http://localhost:8888/core/dist/index.php
So if you entered {$attachment fieldvalue="FORMNAME"}
that would look for a file name "Test" in your root Form Tools folder and upload that if it exists (you're correct, btw, this option doesn't factor in custom upload paths since it's independent of any specific fields).
I guess you could use this feature for advanced stuff: using one of the hook modules to append custom placeholders for use in your emails.
But as it stands, I can't see how this option can work as you've described.... could you double check it's still working?
Hi there,
works with
{$attachment fieldvalue="file_field1"}
, and not{$attachment field="file_field1"}
as stated in the documentation.More than 1 file using
{$attachment fieldvalue="file_field1"}
swiftmailer/template doesn't attach.Also doesn't respect the upload directory settings. The files are uploaded to the ../upload directory, but swiftmailer/template expect the attachment files in ../formtools directory (root folder).