boolean addAttachment (
string
$file
, string
$c_type = 'application/octet-stream'
, string
$name = ''
, boolean
$isfile = true
, string
$encoding = 'base64'
, string
$disposition = 'attachment'
, string
$charset = ''
, string
$language = ''
, string
$location = ''
, string
$n_encoding = null
, string
$f_encoding = null
, string
$description = ''
, string
$h_charset = null
)
Adds an attachment to a message.
string $file
- The file name or the data itself
string $c_type
- The content type of the image
or file.
string $name
- The suggested file name for the data. Only
used, if $file
contains data.
boolean $isfile
- Whether $file
is a file name or not.
string $encoding
- Type of transfer encoding to use
for the file data. Defaults is "base64". For text based files
(eg. scripts/html etc.) this could be given as
"quoted-printable".
string $disposition
- The content-disposition of this file
Defaults to attachment. Possible values: attachment, inline.
string $charset
- The character set of attachment's content.
string $language
- The language of the attachment
string $location
- The RFC 2557.4 location of the attachment
string $n_encoding
- Encoding of the attachment's name in Content-Type
By default filenames are encoded using RFC2231 method
Here you can set RFC2047 encoding (quoted-printable or base64) instead.
string $f_encoding
- Encoding of the attachment's filename
in Content-Disposition header.
string $description
- Content-Description header.
string $h_charset
- The character set of the headers e.g. filename
If not specified, $charset will be used
boolean
- Returns TRUE on success,
PEAR_Error on failure.
Error code | Error message | Reason | Solution |
---|---|---|---|
NULL |
"File is not readable file_name "
|
The file was not found or the script has not enough rights to access the file. | Check the file name and path. Check user and file permissions. |
NULL |
"Could not open file_name "
|
The file is already opened and exclusivly locked by another application. | In the most cases a program opens the file for writing. addAttachment() does no file locking, so this problem is not caused by competitive callings of this function. |
This function can not be called statically.