Problem with email attachment

potter68 05 Feb, 2014
Hello all,

i have problems with attaching a file from my server to the email in chronoforms.

The images show what i did. The email is send to my address but there is no attachment.

What am i doing wrong?

Any answer is welcome.

Greetings Potter
potter68 05 Feb, 2014
Domo origato Mr. Roboto!

But the hack is not working - still the same problem.
GreyHead 05 Feb, 2014
HI potter68,

Please see this FAQ which may be a bit more useful.

Bob
potter68 05 Feb, 2014
Thank you, but it does not help. Btw. i did all threads with attachments.

In the picture you can see the Custom Code field. It goes like this:
<?php
$form->data['attached'] = 'http://ABSOLUTE_PATH/test.pdf';
?>

So, i will have a field called 'attached'. And this field is added to the 'Attachments field' of the Email event like that: {attached}

So what did i miss?

Greetings Potter
Max_admin 05 Feb, 2014
Hi Potter,

Your code will not work because the email action needs an absolute path to the file.

Please try this code:

$form->files["myfile"]["path"] = "absolute path to file here";
$form->files["myfile"]["name"] = "file name here";


You should also use "myfile" in the attachments fields names box, not {myfile}

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
potter68 06 Feb, 2014
Hello,

thanks for that fast reply! But unfortunately, it is still not working.

The pictures show what i did:
1. I changed my PHP snippet the way you told me (compare to img3)
2. I wrote myfile into the attachment field of the email action.

The debug result is shown in img4.

It is much better (at least the path is visible now), but i am still something missing.

Greetings Potter
potter68 07 Feb, 2014
Hello,

i got it finally made! You guys put me on the right way!

The PHP code did change to:
<?php
$form->files["myfile"]["path"] = JPATH_SITE.'/images/downloads/test.pdf';
$form->files["myfile"]["name"] = 'test.pdf';
?>

I did not use the 'http://www.MY_WEBSITE.com' as my PATH variable. Instead, i used the build in 'JPATH_SITE' value (as seen in your FAQ).
Another thing is that you also have to add the document's name to the path.

It's always the detail.
Thanks a lot again for your fast help and that great plugin, Potter
GreyHead 07 Feb, 2014
Hi potter68,

JPATH_SITE is usually the correct prefix to use if you are attaching a file to an email as it gives the server folder path.

JURI::root() is usually the correct prefix to use if you want to add a link in the body of an email.

Note: JURI::root() includes the final / JPATH_SITE doesn't

Bob
This topic is locked and no more replies can be posted.