You are here

public function HTMLMailMime::addAttachment in HTML Mail 8

Same name and namespace in other branches
  1. 8.3 src/Utility/HtmlMailMime.php \Drupal\htmlmail\Utility\HtmlMailMime::addAttachment()

Adds a file to the list of attachments.

Parameters

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

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

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

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

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

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

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

  • attachment (default)
  • inline.

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

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

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

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

  • base64
  • quoted-printable.

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

  • base64
  • quoted-printable.

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

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

array $add_header: (optional) Extra headers.

Return value

bool TRUE if successful; otherwise FALSE.

File

src/Utility/HTMLMailMime.php, line 289
Provides the MailMIME class for creating MIME-formatted email messages.

Class

HTMLMailMime
Class HTMLMailMime.

Namespace

Drupal\htmlmail\Utility

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, array $add_header = []) {

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