EmailComponent Class Info:

Class Declaration:

class EmailComponent extends Object

File name:
cake/libs/controller/components/email.php
Description:

EmailComponent

This component is used for handling Internet Message Format based based on the standard outlined in http://www.rfc-editor.org/rfc/rfc2822.txt

Class Inheritance

Object

Properties:

Show/Hide parent properties
  • additionalParams string

    List of additional headers

    These will NOT be used if you are using safemode and mail()

  • attachments array

    List of files that should be attached to the email.

    Can be both absolute and relative paths

  • bcc array

    Blind Carbon Copy

    List of email's that should receive a copy of the email. The Recipient WILL NOT be able to see this list

  • __boundary string

    If set, boundary to use for multipart mime messages

  • cc array

    Carbon Copy

    List of email's that should receive a copy of the email. The Recipient WILL be able to see this list

  • charset string

    charset the email is sent in

  • delivery string

    What method should the email be sent by

    Supported methods: - mail - smtp - debug

  • filePaths array

    The list of paths to search if an attachment isnt absolute

  • from string

    The mail which the email is sent from

  • __header array

    Temporary store of message header lines

  • headers array

    Associative array of a user defined headers Keys will be prefixed 'X-' as per RFC2822 Section 4.7.5

  • htmlMessage string

    Contains the rendered HTML message if one was sent.

  • layout string

    Layout for the View

  • lineLength integer

    as per RFC2822 Section 2.1.1

  • _lineLength

  • __message array

    Temporary store of message lines

  • messageId mixed

    Whether to generate a Message-ID header for the e-mail. True to generate a Message-ID, False to let it be handled by sendmail (or similar) or a string to completely override the Message-ID.

  • readReceipt string

    The read receipt email

  • replyTo string

    The email the recipient will reply to

  • return string

    The mail that will be used in case of any errors like - Remote mailserver down - Remote user has exceeded his quota - Unknown user

  • sendAs string

    What format should the email be sent in

    Supported formats: - text - html - both

  • __smtpConnection resource

    Variable that holds SMTP connection

  • smtpError string

    Placeholder for any errors that might happen with the smtp mail methods

  • smtpOptions array

    List of options to use for smtp mail method

    Options is: - port - host - timeout - username - password - client

  • subject string

    The subject of the email

  • template string

    Template for the view

  • textMessage string

    Contains the rendered plain text message if one was sent.

  • to string

    Recipient of the email

  • xMailer string

    What mailer should EmailComponent identify itself as

_attachFiles

top

Attach files by adding file contents inside boundaries.

Method defined in:
cake/libs/controller/components/email.php on line 627
Access

private

TODO

: modify to use the core File class?

cakeError

top

Used to report user friendly errors. If there is a file app/error.php or app/app_error.php this file will be loaded error.php is the AppError class it should extend ErrorHandler class.

Parameters:
  • string $method required

    Method to be called in the error class (AppError or ErrorHandler classes)

  • array $messages optional array ( )

    Message that is to be displayed by the error class

Method defined in:
cake/libs/object.php on line 187
Return

error message

Access

public

__construct

top

Class constructor, overridden in descendant classes.

Method defined in:
cake/libs/object.php on line 54

_createboundary

top

Create unique boundary identifier

Method defined in:
cake/libs/controller/components/email.php on line 508
Access

private

_createHeader

top

Create emails headers including (but not limited to) from email address, reply to, bcc and cc.

Method defined in:
cake/libs/controller/components/email.php on line 529
Access

private

_debug

top

Set as controller flash message a debug message showing current settings in component

Method defined in:
cake/libs/controller/components/email.php on line 917
Return

boolean Success

Access

private

dispatchMethod

top

Calls a method on this object with the given parameters. Provides an OO wrapper for call_user_func_array

Parameters:
  • string $method required

    Name of the method to call

  • array $params optional array ( )

    Parameter list to use when calling $method

Method defined in:
cake/libs/object.php on line 107
Return

mixed Returns the result of the method call

Access

public

_encode

top

Encode the specified string using the current charset

Parameters:
  • string $subject required

    String to encode

Method defined in:
cake/libs/controller/components/email.php on line 710
Return

string Encoded string

Access

private

_findFiles

top

Find the specified attachment in the list of file paths

Parameters:
  • string $attachment required

    Attachment file name to find

Method defined in:
cake/libs/controller/components/email.php on line 662
Return

string Path to located file

Access

private

_formatAddress

top

Format a string as an email address

Parameters:
  • string $string required

    String representing an email address

  • $smtp optional false

Method defined in:
cake/libs/controller/components/email.php on line 727
Return

string Email address suitable for email headers or smtp pipe

Access

private

_formatMessage

top

Format the message by seeing if it has attachments.

Parameters:
  • string $message required

    Message to format

Method defined in:
cake/libs/controller/components/email.php on line 604
Access

private

header

top

Sets headers for the message

Parameters:
  • $headers required

Method defined in:
cake/libs/controller/components/email.php on line 518
Access

public

initialize

top

Initialize component

Parameters:
  • object $controller required

    Instantiating controller

  • $settings optional array ( )

Method defined in:
cake/libs/controller/components/email.php on line 307
Access

public

log

top

Convience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.

Parameters:
  • string $msg required

    Log message

  • integer $type optional 2

    Error type constant. Defined in app/config/core.php.

Method defined in:
cake/libs/object.php on line 148
Return

boolean Success of log write

Access

public

_mail

top

Wrapper for PHP mail function used for sending out emails

Method defined in:
cake/libs/controller/components/email.php on line 767
Return

bool Success

Access

private

Object

top

A hack to support __construct() on PHP 4 Hint: descendant classes have no PHP4 class_name() constructors, so this constructor gets called first and calls the top-layer __construct() which (if present) should call parent::__construct()

Method defined in:
cake/libs/object.php on line 43
Return

Object

__openPersistent

top

Open the persistent class file for reading Used by Object::_persist()

Parameters:
  • string $name required

    Name of persisted class

  • string $type optional NULL

    Type of persistance (e.g: registry)

Method defined in:
cake/libs/object.php on line 268
Return

void

Access

private

_persist

top

Checks for a persistent class file, if found file is opened and true returned If file is not found a file is created and false returned If used in other locations of the model you should choose a unique name for the persistent file There are many uses for this method, see manual for examples

Parameters:
  • string $name required

    name of the class to persist

  • $return required

  • string $object required

    the object to persist

  • $type optional NULL

Method defined in:
cake/libs/object.php on line 218
Return

boolean Success

Access

protected

Todo

add examples to manual

_render

top

Render the contents using the current layout and template.

Parameters:
  • string $content required

    Content to render

Method defined in:
cake/libs/controller/components/email.php on line 423
Return

array Email ready to be sent

Access

private

requestAction

top

Calls a controller's method from any location. Can be used to connect controllers together or tie plugins into a main application. requestAction can be used to return rendered views or fetch the return value from controller actions.

Parameters:
  • mixed $url required

    String or array-based url.

  • array $extra optional array ( )

    if array includes the key "return" it sets the AutoRender to true.

Method defined in:
cake/libs/object.php on line 80
Return

mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.

Access

public

reset

top

Reset all EmailComponent internal variables to be able to send out a new email.

Method defined in:
cake/libs/controller/components/email.php on line 396

_savePersistent

top

You should choose a unique name for the persistent file

There are many uses for this method, see manual for examples

Parameters:
  • string $name required

    name used for object to cache

  • object $object required

    the object to persist

Method defined in:
cake/libs/object.php on line 247
Return

boolean true on save, throws error if file can not be created

Access

protected

send

top

Send an email using the specified content, template and layout

Parameters:
  • mixed $content optional NULL

    Either an array of text lines, or a string with contents If you are rendering a template this variable will be sent to the templates as $content

  • string $template optional NULL

    Template to use when sending email

  • string $layout optional NULL

    Layout to use to enclose email body

Method defined in:
cake/libs/controller/components/email.php on line 333
Return

boolean Success

Access

public

_set

top

Allows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.

Parameters:
  • array $properties optional array ( )

    An associative array containing properties and corresponding values.

Method defined in:
cake/libs/object.php on line 166
Return

void

Access

protected

_smtp

top

Sends out email via SMTP

Method defined in:
cake/libs/controller/components/email.php on line 787
Return

bool Success

Access

private

_smtpSend

top

Protected method for sending data to SMTP connection

Parameters:
  • string $data required

    data to be sent to SMTP server

  • mixed $checkCode optional '250'

    code to check for in server response, false to skip

Method defined in:
cake/libs/controller/components/email.php on line 883
Return

bool Success

Access

protected

startup

top

Startup component

Parameters:
  • object $controller required

    Instantiating controller

Method defined in:
cake/libs/controller/components/email.php on line 321
Access

public

_stop

top

Stop execution of the current script. Wraps exit() making testing easier.

Parameters:
  • $status optional 0

Method defined in:
cake/libs/object.php on line 135
Return

void

Access

public

_strip

top

Remove certain elements (such as bcc:, to:, %0a) from given value

Parameters:
  • string $value required

    Value to strip

  • boolean $message optional false

    Set to true to indicate main message content

Method defined in:
cake/libs/controller/components/email.php on line 747
Return

string Stripped value

Access

private

toString

top

Object-to-string conversion. Each class can override this method as necessary.

Method defined in:
cake/libs/object.php on line 64
Return

string The name of this class

Access

public

_wrap

top

Wrap the message using EmailComponent::$lineLength

Parameters:
  • string $message required

    Message to wrap

Method defined in:
cake/libs/controller/components/email.php on line 682
Return

array Wrapped message

Access

private