Forums

email attachment setup

craude 11 Jul, 2013
I cant get that to work:
<?php
$form->files['my_file'] = array(
  'name' => $my_file_name
  'original_name' => '',
  'path' => $my_file_path.$my_file_name,
  'size' => '',
  'link' => str_replace(JPATH_SITE.DS, JURI::root(), $my_file_path.$my_file_name)
);
?>


with:
my_file = tandc
my_file_name = tandc.pdf
my_file_path = images

it becomes:
<?php
$form->files['tandc'] = array(
  'name' => $tandc.pdf
  'original_name' => '',
  'path' => $images.$tandc.pdf,
  'size' => '',
  'link' => str_replace(JPATH_SITE.DS, JURI::root(), $images.$tandc.pdf)
);
?>

Attachments fields name = tandc

What is wrong? thx
V4 RC3.5.3
GreyHead 12 Jul, 2013
Hi craude,

You can't do this $tandc.pdf in PHP. Try $tandc.'.pdf'

Bob
craude 12 Jul, 2013
Thank you, I changed it, still no attachment. I dont even know where to start looking for the bug ...

<?php
$form->files['tandc'] = array(
  'name' => $tandc.'.pdf'
  'original_name' => '',
  'path' => $images.$tandc.'.pdf',
  'size' => '',
  'link' => str_replace(JPATH_SITE.DS, JURI::root(), $images.$tandc.'.pdf')
);
?>
GreyHead 12 Jul, 2013
Hi craude,

What do you see if you add this in a Custom Code action:
<?php
echo'<div>$form->files: '.print_r($form->files, true).'</div>';
?>
craude 12 Jul, 2013
The form does not look different when I test it with your code. I put it in a "Custom Code" action within "On Submit". But the file that is supposed to be attached exists:
http://www.digitale-lernumgebung.de/images/tandc.pdf
GreyHead 13 Jul, 2013
Hi craude,

That code should have printed out the $form->files array to the screen.

Bob
craude 13 Jul, 2013
Thanks ... it didn't. Where to look next?
GreyHead 13 Jul, 2013
Hi craude,

Debugging the code is all that is left I'm afraid :-(

If that doesn't print out then add a Debugger, it should display then.

Bob
craude 01 Aug, 2013
I cant provide a fix. I gave up on that one. I included the text of the PDF in question into the email.
yvet 14 Jan, 2014
Hello Bob,

Got it all working. The system makes an excellent pdf... but I can not get it attached in the email and also a link to the file is not working.
I'm using the custom code like this. The email is send, the link is showing, but not the file name. Tried about everything. Can you please help me?

<?php
$form->data['pdf_link'] = "<a href='/bestanden_leden/{$form->files['name']}' >klik hier om het bestand te downloaden</a>";
?>


the standard code is not working at all (no link).
<?php
$form->data['pdf_link'] = "<a href='{$form->files['cf_pdf_file']['link']}' >Click here</a>";
?>
GreyHead 15 Jan, 2014
Hi yvet,

The PDF action must be before the Email action and it must be configured to save the PDF file to the server. If you add a Debugger action after this it should (I hope) show you the name and path of the new PDF file so that you can use it in the email.

Bob
yvet 15 Jan, 2014
Hello Bob,

Thank you for your fast reply!

I have an email action after the PDF action. And it already (forgot to tell) saved the pdf file successfully to the server.

This is what the debugger says after the submit:
Attachments
array ( )
56
Result
An email has been SENT successfully from (website ****sla.nl)webmaster@*****sla.nl to info@*****sla.nl,****man@tiscali.nl
Body
In deze mail de pdf van de zojuist verzonden nieuwe inschrijving voor lidmaatschap. klik hier om het bestand te downloaden 

Submitted by *********.39
Attachments
array ( )
bestanden_leden/cf_pdf_file_20140115122216.pdf has been uploaded OK.


I can not find the (coded)name for the file. I tried "{form_name}_{datetime_string}.pdf" and lots more....

If this is the right code in the custom code (after pdf action and before email action)... what am I doing wrong?
<?php
$form->data['pdf_link'] = "<a href='{$form->files['cf_pdf_file']['link']}' >Click here</a>";
?>


Debugger says:
[pdf_link] => Click here
is redirecting to "http://my-site***.nl/index.php"

In the email action I have in the "Attachments fields name" "cf_pdf_file".

Hope you see what I'm missing.
This topic is locked and no more replies can be posted.