PHP Class Tools\Mailer\Email

Inheritance: extends Cake\Mailer\Email, use trait Cake\Log\LogTrait
Afficher le fichier Open project: dereuromark/cakephp-tools Class Usage Examples

Protected Properties

Свойство Type Description
$_debug boolean | null
$_error string | null
$_log array
$_priority integer | null
$_wrapLength integer | null

Méthodes publiques

Méthode Description
__construct ( string | null $config = null )
addAttachment ( string $file, string | null $name = null, array $fileInfo = [] ) Add an attachment from file
addBlobAttachment ( string $content, string $filename, string | null $mimeType = null, array $fileInfo = [] ) Add an attachment as blob
addEmbeddedAttachment ( string $file, string | null $name = null, string | null $contentId = null, array $options = [] ) : string | $this Add an inline attachment from file
addEmbeddedBlobAttachment ( string $content, string $filename, string | null $mimeType = null, string | null $contentId = null, array $options = [] ) : string | $this Add an inline attachment as blob
attachments ( mixed | null $attachments = null ) : array | $this Overwrite to allow mimetype detection
getError ( ) : string Returns the error if existent
layout ( string | boolean $layout = false ) Change the layout
priority ( integer | null $priority = null ) : integer | $this Set/Get priority
profile ( mixed $config = null ) : string | null | $this Ovewrite to allow custom enhancements
reset ( ) : void EmailLib::resetAndSet()
send ( string | array | null $message = null ) : boolean Set the body of the mail as we send it.
validates ( ) : boolean Validate if the email has the required fields necessary to make send() work.
wrapLength ( integer | null $length = null ) : integer | $this Set/Get wrapLength

Méthodes protégées

Méthode Description
_attachFiles ( string | null $boundary = null ) : array Attach non-embedded files by adding file contents inside boundaries.
_attachInlineFiles ( string | null $boundary = null ) : array Attach inline/embedded files to the message.
_getMime ( string $filename, string $default = 'application/octet-stream' ) : string Try to find mimetype by file extension
_getMimeByExtension ( string $ext, string $default = 'application/octet-stream' ) : mixed
_isEmbeddedAttachment ( string $file, string $name ) : boolean | string Returns if this particular file has already been attached as embedded file with this exact name to prevent the same image to overwrite each other and also to only send this image once.
_isEmbeddedBlobAttachment ( string $content, string $name ) : boolean | string Returns if this particular file has already been attached as embedded file with this exact name to prevent the same image to overwrite each other and also to only send this image once.
_logEmail ( string $level = LogLevel::INFO ) : void
_readFile ( string $path ) : string Read the file contents and return a base64 version of the file contents.
_wrap ( string $message, integer $wrapLength = CakeEmail::LINE_LENGTH_MUST ) : array Fix line length

Method Details

__construct() public méthode

public __construct ( string | null $config = null )
$config string | null

_attachFiles() protected méthode

CUSTOM FIX: blob data support
protected _attachFiles ( string | null $boundary = null ) : array
$boundary string | null Boundary to use. If null, will default to $this->_boundary
Résultat array An array of lines to add to the message

_attachInlineFiles() protected méthode

CUSTOM FIX: blob data support
protected _attachInlineFiles ( string | null $boundary = null ) : array
$boundary string | null Boundary to use. If null, will default to $this->_boundary
Résultat array An array of lines to add to the message

_getMime() protected méthode

Try to find mimetype by file extension
protected _getMime ( string $filename, string $default = 'application/octet-stream' ) : string
$filename string File name
$default string default MimeType
Résultat string Mimetype (falls back to `application/octet-stream`)

_getMimeByExtension() protected méthode

protected _getMimeByExtension ( string $ext, string $default = 'application/octet-stream' ) : mixed
$ext string
$default string
Résultat mixed

_isEmbeddedAttachment() protected méthode

Allows multiple usage of the same embedded image (using the same cid)
protected _isEmbeddedAttachment ( string $file, string $name ) : boolean | string
$file string
$name string
Résultat boolean | string CID of the found file or false if no such attachment can be found

_isEmbeddedBlobAttachment() protected méthode

Allows multiple usage of the same embedded image (using the same cid)
protected _isEmbeddedBlobAttachment ( string $content, string $name ) : boolean | string
$content string
$name string
Résultat boolean | string CID of the found file or false if no such attachment can be found

_logEmail() protected méthode

protected _logEmail ( string $level = LogLevel::INFO ) : void
$level string
Résultat void

_readFile() protected méthode

Overwrite parent to avoid File class and file_exists to false negative existent remove images. Also fixes file_get_contents (used via File class) to close the connection again after getting remote files. So far it would have kept the connection open in HTTP/1.1.
protected _readFile ( string $path ) : string
$path string The absolute path to the file to read.
Résultat string File contents in base64 encoding

_wrap() protected méthode

Fix line length
protected _wrap ( string $message, integer $wrapLength = CakeEmail::LINE_LENGTH_MUST ) : array
$message string Message to wrap
$wrapLength integer
Résultat array Wrapped message

addAttachment() public méthode

Add an attachment from file
public addAttachment ( string $file, string | null $name = null, array $fileInfo = [] )
$file string Absolute path
$name string | null
$fileInfo array

addBlobAttachment() public méthode

Add an attachment as blob
public addBlobAttachment ( string $content, string $filename, string | null $mimeType = null, array $fileInfo = [] )
$content string Blob data
$filename string to attach it
$mimeType string | null (leave it empty to get mimetype from $filename)
$fileInfo array

addEmbeddedAttachment() public méthode

Options: - mimetype - contentDisposition
public addEmbeddedAttachment ( string $file, string | null $name = null, string | null $contentId = null, array $options = [] ) : string | $this
$file string Absolute path
$name string | null (optional)
$contentId string | null (optional)
$options array Options
Résultat string | $this CID or $this

addEmbeddedBlobAttachment() public méthode

Options: - contentDisposition
public addEmbeddedBlobAttachment ( string $content, string $filename, string | null $mimeType = null, string | null $contentId = null, array $options = [] ) : string | $this
$content string Blob data
$filename string to attach it
$mimeType string | null (leave it empty to get mimetype from $filename)
$contentId string | null (optional)
$options array Options
Résultat string | $this $contentId or $this

attachments() public méthode

Overwrite to allow mimetype detection
public attachments ( mixed | null $attachments = null ) : array | $this
$attachments mixed | null
Résultat array | $this

getError() public méthode

Returns the error if existent
public getError ( ) : string
Résultat string

layout() public méthode

Change the layout
public layout ( string | boolean $layout = false )
$layout string | boolean Layout to use (or false to use none)

priority() public méthode

Set/Get priority
public priority ( integer | null $priority = null ) : integer | $this
$priority integer | null 1 (highest) to 5 (lowest)
Résultat integer | $this

profile() public méthode

Ovewrite to allow custom enhancements
public profile ( mixed $config = null ) : string | null | $this
$config mixed
Résultat string | null | $this

reset() public méthode

EmailLib::resetAndSet()
public reset ( ) : void
Résultat void

send() public méthode

Note: the text can be an array, each element will appear as a seperate line in the message body. Do NOT pass a message if you use $this->set() in combination with templates
public send ( string | array | null $message = null ) : boolean
$message string | array | null Message
Résultat boolean Success

validates() public méthode

Assumes layouting (does not check on content to be present or if view/layout files are missing).
public validates ( ) : boolean
Résultat boolean Success

wrapLength() public méthode

Set/Get wrapLength
public wrapLength ( integer | null $length = null ) : integer | $this
$length integer | null Must not be more than CakeEmail::LINE_LENGTH_MUST
Résultat integer | $this

Property Details

$_debug protected_oe property

protected bool|null $_debug
Résultat boolean | null

$_error protected_oe property

protected string|null $_error
Résultat string | null

$_log protected_oe property

protected array $_log
Résultat array

$_priority protected_oe property

protected int|null $_priority
Résultat integer | null

$_wrapLength protected_oe property

protected int|null $_wrapLength
Résultat integer | null