Adding attachments to messages

phpList supports the adding of attachments to your messages. The config/config.php file warns that this feature is experimental and may result in large e-mails. It also cautions that it's generally more acceptable to send a link to a file download, instead of including that file as an attachment in the message sent to the subscriber.

However, there are many situations where you might want to include attachments and doing so is quite simple.

To enable attachments, look for this line in config/config.php:

define("ALLOW_ATTACHMENTS",0);

Change ALLOW_ATTACHMENTS from 0 to 1 to turn on attachment support.

You'll note on the send a message page that there's an additional tab labeled Attach. Click on this tab while preparing your message to add attachments. The attachment tab will display the current (server-set) size limits and allow you to browse for new files to attach:

Adding attachments to messages

It's recommended that you add a description of each attachment, although this is only for your own clarity and is not visible to your readers. Click on Add (and save) when you've selected the file (on your local system) to attach and entered an optional description:

Adding attachments to messages

phpList will confirm the successful attachment of the file and display a summary of all files attached, including a sequence number (this will increment over time with every new attachment), a filename, description, and file size.

Note

It's a good idea to do a "sanity-check" at this point and make sure that the file attachment won't make the message so large that it will cause inconvenience to your readers.

To add another file, repeat this process, one file at a time.

Adding multiple files simultaneously

While phpList doesn't impose a limit on how many attachments can be added to a message, it does (by default) expect you to attach them one at a time.

You may have a requirement to attach several files to every message and find the one-at-a-time approach laborious. phpList can be configured to attach many files simultaneously.

Look for this line in config/config.php:

define("NUMATTACHMENTS",1);

And change NUMATTACHMENTS from 1 to the number you require.

For example, after changing this value to 2, you're presented with two file-attachment forms on the same page:

Adding multiple files simultaneously

Note

Note that clicking any of the Add (and save) buttons will add all attachments you've selected with the Browse button. The reason this button is repeated for every upload is that (a) it's easier to code and (b) while you have defined a maximum concurrent attachment limit, you may sometimes want to attach less than the maximum number of files.

Attaching files stored on your web server

So far, we've covered uploading attachments using your web browser. You may also want to attach files that are already on your web server. (For example, perhaps you want to attach a report that is automatically created by another system and saved to a location on the web server).

To enable filesystem attachments, look for the following line in config/config.php:

define("FILESYSTEM_ATTACHMENTS",0);

Change FILESYSTEM_ATTACHMENTS from 0 to 1 to enable filesystem attachments.

Now, on the send a message page, under the Attach tab, in addition to a Browse button to upload the file, you also have an input field allowing you to specify a filesystem location for this file:

Attaching files stored on your web server

Note that no validation is done at this point. That is, phpList doesn't stop you if the file doesn't exist. Your only indication that this file may not exist is the file size (zero in the following example):

Attaching files stored on your web server

If the file size is a positive number, then phpList is able to find the file, and therefore attach it (assuming that the web server user has permission to read that file on the filesystem).

Note that phpList will not warn you of a failure to attach a filesystem fileā€”it will silently ignore it. That is, in the following example, only the second attachment (testattachment.txt) will actually be sent, but no errors will be produced:

Attaching files stored on your web server

However, when examining the message after sending using the Edit Message link, the Attach tab will show which attachments were successfully attached:

Attaching files stored on your web server

Securing your attachments stored on the web server

By default, any attachments you upload are stored in /tmp on your web server. This is not ideal, as on a shared host, other users might also have access to these files.

It's recommended that you create a dedicated directory for your attachments instead. It may be best to create an "attachments" folder at the same level as the folder which contains your publicly accessible HTML and PHP files (but not in it!), ensuring that this directory is available to phpList but not to normal web users.

Note

Make sure that the web server has "write" access to this directory, or else it won't be able to save the attachments you upload.

When you've created this directory, open config/config.php and look for this line:

$attachment_repository = '/tmp';

Change the value of $attachment_repository to refer to the full path to the new "attachments" directory you created, for example: /home/myuser/mywebsite/attachments.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.103.210