The script allows you to send an arbitrary number of attachments. In order to be attached to an e-mail, a file would have to be uploaded by the form user beforehand. If you want to use this feature, please follow these steps:

Step 1

Copy the file form.tpl.html from the folder /templates/example_upload_attachment/ to the folder /templates/. That will replace the existing form.tpl.html.

The new form.tpl.html contains following additional form field:

<input type="file" name="my_attachment" />

You are free to change the name of the field or to add more fields of the type file. If you have more than one upload field, please make sure each field has a different name (name="").

Furthermore, it is important that the HTML tag <form> contains following attribute:


It would look like this:

<form action="{script_self}" method="POST" enctype="multipart/form-data">

Otherwise, the script won't send the attachments.

The mail template does not require any changes.

Step 2

Please make sure that the folder /temp/ is writable (chmod 777).

Step 3

Activate the attachment feature by setting the variable $attachment = 'yes' in index.php.


Following additional options can be set in index.php:


This variable contains a comma separated list of file types that are allowed to be sent as attachment.

Please note: You should be very careful about what file types you allow for upload. Please bear in mind that in the end you will receive those files in your inbox.


This variable contains the maximum size of an attachment in bytes. The maximum attachment size is applied for each uploaded file. For example: You have set a maximum attachment size of 1024 Kbytes and have three upload fields. Each of the three uploaded files can be 1024 Kbytes which results in 3072 Kbytes for all three files together.

Please note: Upload fields cannot be set as required fields.

Earlier versions of the script did not allow the combination of attachments and HTML formatted e-mails. As of version 3.2 this is no longer the case.