Form Email Element Issue

FatFingers

New Member
Hi,
I would like to email a word document to a selected user.
I have set up a list which has a field element of Send To
I have then added the email plugin to the form
the email to is set to the Send To element value and this works to send the email out but Im having issues with the attachments options.
I have set the Attachment Type to docx and added:

$file[] = 'images/Etching/InitialrequestV1.docx';
return $file;


To the Attachments (eval)

The email is sent to the recipient however the attachment is a random name and is corrupt and cannot be opened.
I have tried using PDF as well but have the same corrupt issue when the mail is received.
What am I doing wrong ? and can I get it to use the true filename rather than a random one being generated ?

Thanks in advance.
 
Don't set the Attachment Type, it's for sending the form content, see the Tooltip
OPTIONAL - if a file extension (like csv) is provided, the message content (output of your template) will also be attached with a random filename (using the specified extension). If not specified, not attachment is sent.
 
As per the tooltip on the "Attachments (eval)" option:

needs to return an array of full path name(s)

You are returning a relative path name. Also, you are trying to use an array variable without setting it up. Try ...

Code:
return array(JPATH_ROOT . '/images/Etching/InitialrequestV1.docx');

The code you had, which does ...

Code:
$file[] = 'images/Etching/InitialrequestV1.docx';

... will throw an error because PHP doesn't know that $file should be an array. You would have to do ...

Code:
$file = array();
$file[] = 'images/Etching/InitialrequestV1.docx';

... but as you are only returning a single entry in the array, it's easier to do it with the line I gave above.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top