You are here

public function MailMIME::addAttachment in Mail MIME 6

Same name and namespace in other branches
  1. 8.2 mailmime.inc \MailMIME::addAttachment()
  2. 6.2 mailmime.inc \MailMIME::addAttachment()
  3. 7.2 mailmime.inc \MailMIME::addAttachment()
  4. 7 mailmime.inc \MailMIME::addAttachment()

Adds a file to the list of attachments.

Parameters

$file: The filename to attach, or the file contents itself.

$content_type: (optional) The content-type, such as 'application/x-pdf'.

$name: (optional) The filename of the attachment, if $is_file is FALSE.

$is_file: (optional) FALSE if $file contains file data rather than a filename. Defaults to TRUE.

$encoding: (optional) The encoding to use for the file data. May be one of:

  • 7bit:
  • 8bit:
  • base64: (default)
  • quoted-printable

$disposition: (optional) The content-disposition of this file. May be one of:

  • attachment: (default)
  • inline:

$charset: (optional) The character set of the attachment's content.

$language: (optional) The language of the attachment.

$location: (optional) The RFC 2557.4 location of the attachment.

$name_encoding: (optional) The encoding to use for the attachment name, instead of the default RFC2231 encoding. May be one of:

  • base64
  • quoted-printable

$filename_encoding: (optional) The encoding to use for the attachment filename, instead of the default RFC2231 encoding. May be one of:

  • base64
  • quoted-printable

$description: (optional) The value to use for the Content-Description header.

$header_charset: (optional) The character set to use for this part's MIME headers.

Return value

TRUE if successful; otherwise FALSE.

File

./mailmime.inc, line 302
Provides the MailMIME class for creating MIME-formatted email messages.

Class

MailMIME
The MailMIME class is used to create MIME email messages.

Code

public function addAttachment($file, $content_type = 'application/octet-stream', $name = '', $is_file = TRUE, $encoding = 'base64', $disposition = 'attachment', $charset = '', $language = '', $location = '', $name_encoding = NULL, $filename_encoding = NULL, $description = '', $header_encoding = NULL) {

  // @todo Set content_type with mimedetect if possible.
  return MailMIME::successful(parent::addAttachment($file, $content_type, $name, $is_file, $encoding, $disposition, $charset, $language, $locatoin, $name_encoding, $filename_encoding, $description, $header_encoding));
}