CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 1.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.2
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbAclSchema
  • DbConfigTask
  • DboAdodb
  • DboDb2
  • DboFirebird
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOdbc
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • DboSybase
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • Flay
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • i18nSchema
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JsHelper
  • JsHelperObject
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginTask
  • ProjectTask
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • SessionsSchema
  • Set
  • Shell
  • String
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • __enclose
  • make_clean_css
  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • write_css_cache

Class EmailComponent

Object class, allowing __construct and __destruct in PHP4.

Also includes methods for logging and the special method RequestAction, to call other Controllers' Actions from anywhere.

Object
Extended by EmailComponent
Package: cake\cake\libs
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: The MIT License
Location: controller/components/email.php

Properties summary

  • $__boundary public
    string
    If set, boundary to use for multipart mime messages
  • $__header public
    array
    Temporary store of message header lines
  • $__message public
    array
    Temporary store of message lines
  • $__smtpConnection public
    resource
    Variable that holds SMTP connection
  • $_debug public
    string
    If set to true, the mail method will be auto-set to 'debug'
  • $_lineLength public
  • $additionalParams public
    string
    List of additional headers
  • $attachments public
    array
    List of files that should be attached to the email.
  • $bcc public
    array
    Blind Carbon Copy
  • $cc public
    array
    Carbon Copy
  • $charset public
    string
    charset the email is sent in
  • $date public
    string

    The date to put in the Date: header. This should be a date conformant with the RFC2822 standard. Leave null, to have today's date generated.

  • $delivery public
    string
    What method should the email be sent by
  • $filePaths public
    array
    The list of paths to search if an attachment isnt absolute
  • $from public
    string
    The mail which the email is sent from
  • $headers public
    array

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

  • $layout public
    string
    Layout for the View
  • $lineFeed public
    string

    Line feed character(s) to be used when sending using mail() function If null PHP_EOL is used. RFC2822 requires it to be CRLF but some Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used).

  • $lineLength public
    integer
    as per RFC2822 Section 2.1.1
  • $readReceipt public
    string
    The read receipt email
  • $replyTo public
    string
    The email the recipient will reply to
  • $return public
    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 public
    string
    What format should the email be sent in
  • $smtpError public
    string

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

  • $smtpOptions public
    array
    List of options to use for smtp mail method
  • $subject public
    string
    The subject of the email
  • $template public
    string
    Template for the view
  • $to public
    string
    Recipient of the email
  • $xMailer public
    string
    What mailer should EmailComponent identify itself as

Inherited Properties

  • _log

Method Summary

  • __attachFiles() public
    Attach files by adding file contents inside boundaries.
  • __createBoundary() public
    Create unique boundary identifier
  • __createHeader() public

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

  • __debug() public
    Set as controller flash message a debug message showing current settings in component
  • __encode() public
    Encode the specified string using the current charset
  • __findFiles() public
    Find the specified attachment in the list of file paths
  • __formatAddress() public
    Format a string as an email address
  • __formatMessage() public
    Format the message by seeing if it has attachments.
  • __mail() public
    Wrapper for PHP mail function used for sending out emails
  • __renderTemplate() public
    Render the contents using the current layout and template.
  • __smtp() public
    Sends out email via SMTP
  • __smtpSend() public
    Private method for sending data to SMTP connection
  • __strip() public

    Remove certain elements (such as bcc:, to:, %0a) from given value. Helps prevent header injection / mainipulation on user content.

  • __wrap() public
    Wrap the message using EmailComponent::$lineLength
  • _getSocket() public
    Helper method to get socket, overridden in tests
  • initialize() public
    Initialize component
  • reset() public
    Reset all EmailComponent internal variables to be able to send out a new email.
  • send() public
    Send an email using the specified content, template and layout
  • startup() public
    Startup component

Method Detail

__attachFiles() public ¶

__attachFiles( )

Attach files by adding file contents inside boundaries.

Todo:
modify to use the core File class?

__createBoundary() public ¶

__createBoundary( )

Create unique boundary identifier

__createHeader() public ¶

__createHeader( )

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

__debug() public ¶

__debug( )

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

Returns
boolean
Success

__encode() public ¶

__encode( string $subject )

Encode the specified string using the current charset

Parameters
string $subject
String to encode
Returns
string
Encoded string

__findFiles() public ¶

__findFiles( string $attachment )

Find the specified attachment in the list of file paths

Parameters
string $attachment
Attachment file name to find
Returns
string
Path to located file

__formatAddress() public ¶

__formatAddress( string $string , $smtp = false )

Format a string as an email address

Parameters
string $string
String representing an email address
$smtp optional false
Returns
string
Email address suitable for email headers or smtp pipe

__formatMessage() public ¶

__formatMessage( string $message )

Format the message by seeing if it has attachments.

Parameters
string $message
Message to format

__mail() public ¶

__mail( )

Wrapper for PHP mail function used for sending out emails

Returns
boolean
Success

__renderTemplate() public ¶

__renderTemplate( string $content )

Render the contents using the current layout and template.

Parameters
string $content
Content to render
Returns
array
Email ready to be sent

__smtp() public ¶

__smtp( )

Sends out email via SMTP

Returns
boolean
Success

__smtpSend() public ¶

__smtpSend( string $data , mixed $checkCode = '250' )

Private method for sending data to SMTP connection

Parameters
string $data
data to be sent to SMTP server
mixed $checkCode optional '250'
code to check for in server response, false to skip
Returns
boolean
Success

__strip() public ¶

__strip( string $value , boolean $message = false )

Remove certain elements (such as bcc:, to:, %0a) from given value. Helps prevent header injection / mainipulation on user content.

Parameters
string $value
Value to strip
boolean $message optional false
Set to true to indicate main message content
Returns
string
Stripped value

__wrap() public ¶

__wrap( string $message )

Wrap the message using EmailComponent::$lineLength

Parameters
string $message
Message to wrap
Returns
array
Wrapped message

_getSocket() public ¶

_getSocket( array $config )

Helper method to get socket, overridden in tests

Parameters
array $config
Config data for the socket.

initialize() public ¶

initialize( object $controller , $settings = array() )

Initialize component

Parameters
object $controller
Instantiating controller
$settings optional array()

reset() public ¶

reset( )

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

send() public ¶

send( mixed $content = null , string $template = null , string $layout = null )

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
string $template optional null
Template to use when sending email
string $layout optional null
Layout to use to enclose email body
Returns
boolean
Success

startup() public ¶

startup( object $controller )

Startup component

Parameters
object $controller
Instantiating controller

Methods inherited from Object

Object() public ¶

Object( )

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()

Returns
Object

__construct() public ¶

__construct( )

Class constructor, overridden in descendant classes.

__openPersistent() public ¶

__openPersistent( string $name , string $type = null )

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

Parameters
string $name
Name of persisted class
string $type optional null
Type of persistance (e.g: registry)

_persist() public ¶

_persist( string $name , string $return , $object , $type = null )

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
name of the class to persist
string $return
$object the object to persist
$object
$type optional null
Returns
boolean
Success

_savePersistent() public ¶

_savePersistent( string $name , object $object )

You should choose a unique name for the persistent file

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

Parameters
string $name
name used for object to cache
object $object
the object to persist
Returns
boolean
true on save, throws error if file can not be created

_set() public ¶

_set( array $properties = array() )

Allows setting of multiple properties of the object in a single line of code.

Parameters
array $properties optional array()
An associative array containing properties and corresponding values.

_stop() public ¶

_stop( $status = 0 )

Stop execution of the current script

Parameters
$status optional 0
http://php.net/exit for values

cakeError() public ¶

cakeError( string $method , array $messages = array() )

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
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
Returns
error
message

dispatchMethod() public ¶

dispatchMethod( string $method , array $params = array() )

Calls a method on this object with the given parameters. Provides an OO wrapper for call_user_func_array, and improves performance by using straight method calls in most cases.

Parameters
string $method
Name of the method to call
array $params optional array()
Parameter list to use when calling $method
Returns
mixed
Returns the result of the method call

log() public ¶

log( string $msg , integer $type = LOG_ERROR )

API for logging events.

Parameters
string $msg
Log message
integer $type optional LOG_ERROR
Error type constant. Defined in app/config/core.php.
Returns
boolean
Success of log write

requestAction() public ¶

requestAction( mixed $url , array $extra = array() )

Calls a controller's method from any location.

Parameters
mixed $url
String or array-based url.
array $extra optional array()
if array includes the key "return" it sets the AutoRender to true.
Returns
mixed

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


toString() public ¶

toString( )

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

Returns
string
The name of this class

Properties detail

$__boundary ¶

public string

If set, boundary to use for multipart mime messages

null

$__header ¶

public array

Temporary store of message header lines

array()

$__message ¶

public array

Temporary store of message lines

array()

$__smtpConnection ¶

public resource

Variable that holds SMTP connection

null

$_debug ¶

public string

If set to true, the mail method will be auto-set to 'debug'

false

$_lineLength ¶

public
Deprecated
see lineLength
null

$additionalParams ¶

public string

List of additional headers

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

null

$attachments ¶

public array

List of files that should be attached to the email.

Can be both absolute and relative paths

array()

$bcc ¶

public 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

array()

$cc ¶

public array

Carbon Copy

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

array()

$charset ¶

public string

charset the email is sent in

'utf-8'

$date ¶

public string

The date to put in the Date: header. This should be a date conformant with the RFC2822 standard. Leave null, to have today's date generated.

null

$delivery ¶

public string

What method should the email be sent by

Supported methods: - mail - smtp - debug

'mail'

$filePaths ¶

public array

The list of paths to search if an attachment isnt absolute

array()

$from ¶

public string

The mail which the email is sent from

null

$headers ¶

public array

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

array()

$layout ¶

public string

Layout for the View

'default'

$lineFeed ¶

public string

Line feed character(s) to be used when sending using mail() function If null PHP_EOL is used. RFC2822 requires it to be CRLF but some Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used).

null

$lineLength ¶

public integer

as per RFC2822 Section 2.1.1

70

$readReceipt ¶

public string

The read receipt email

null

$replyTo ¶

public string

The email the recipient will reply to

null

$return ¶

public string

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

null

$sendAs ¶

public string

What format should the email be sent in

Supported formats: - text - html - both

'text'

$smtpError ¶

public string

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

null

$smtpOptions ¶

public array

List of options to use for smtp mail method

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

array(
    'port'=> 25, 'host' => 'localhost', 'timeout' => 30
)

$subject ¶

public string

The subject of the email

null

$template ¶

public string

Template for the view

null

$to ¶

public string

Recipient of the email

null

$xMailer ¶

public string

What mailer should EmailComponent identify itself as

'CakePHP Email Component'
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs