CakePHP email class.
This class is used for handling Internet Message Format based based on the standard outlined in http://www.rfc-editor.org/rfc/rfc2822.txt
string
'CakePHP Email'
string
'/^((?:[\p{L}0-9.!#$%&\'*+\/=?^_`{|}~-]+)*@[\p{L}0-9-.]+)$/ui'
integer
998
integer
78
string
'html'
string
'text'
$_appCharset
protected string
$_attachments
protected array
$_bcc
protected array
$_boundary
protected string
$_cc
protected array
$_charset8bit
protected array
$_config
protected string|array
$_configClass
protected string
$_configInstance
protected EmailConfig
$_contentTypeCharset
protected array
$_domain
protected string
Domain for messageId generation. Needs to be manually set for CLI mailing as env('HTTP_HOST') is empty
$_emailFormat
protected string
$_emailFormatAvailable
protected array
$_emailPattern
protected string
$_from
protected array
$_headers
protected array
Associative array of a user defined headers Keys will be prefixed 'X-' as per RFC2822 Section 4.7.5
$_helpers
protected array
$_htmlMessage
protected string
$_layout
protected string
$_message
protected array
$_messageId
protected boolean|string
$_readReceipt
protected array
$_replyTo
protected array
$_returnPath
protected array
The mail that will be used in case of any errors like - Remote mailserver down - Remote user has exceeded his quota - Unknown user
$_sender
protected array
$_subject
protected string
$_template
protected string
$_textMessage
protected string
$_theme
protected array
$_to
protected array
$_transportClass
protected $_transportName
protected string
$_viewRender
protected string
$_viewVars
protected array
$charset
public string
$headerCharset
public string
Charset the email header is sent in If null, the $charset property will be used as default
Translates a string for one charset to another if the App.encoding value differs and the mb_convert_encoding function exists
Build and set all the view properties needed to render the templated emails. If there is no template set, the $content will be returned in a hash of the text content types for the email.
__construct( array|string $config null )
Constructor
$config
optional null _addEmail( string $varName , string|array $email , string $name )
Add email
$varName
$email
String with email, Array with email as key, name as value or email as value (without name)
$name
CakeEmail
SocketException
_applyConfig( array $config )
Apply the config to an instance
$config
ConfigureException
When configuration file cannot be found, or is missing the named config.
_attachFiles( string $boundary null )
Attach non-embedded files by adding file contents inside boundaries.
$boundary
optional null _attachInlineFiles( string $boundary null )
Attach inline/embedded files to the message.
$boundary
optional null _encode( string $text )
Encode the specified string using the current charset
$text
_encodeString( string $text , string $charset )
Translates a string for one charset to another if the App.encoding value differs and the mb_convert_encoding function exists
$text
$charset
_formatAddress( array $address )
Format addresses
If the address contains non alphanumeric/whitespace characters, it will be quoted as characters like :
and ,
are known to cause issues in address header fields.
$address
_getContentTransferEncoding( )
Return the Content-Transfer Encoding value based on the set charset
_getContentTypeCharset( )
Return charset value for Content-Type.
Checks fallback/compatibility types which include workarounds for legacy japanese character sets.
_getTypes( )
Gets the text body types that are in this email message
_readFile( string $path )
Read the file contents and return a base64 version of the file contents.
$path
_render( array $content )
Render the body of the email.
$content
_renderTemplates( string $content )
Build and set all the view properties needed to render the templated emails. If there is no template set, the $content will be returned in a hash of the text content types for the email.
$content
_setEmail( string $varName , string|array $email , string $name )
Set email
$varName
$email
String with email, Array with email as key, name as value or email as value (without name)
$name
CakeEmail
_setEmailSingle( string $varName , string|array $email , string $name , string $throwMessage )
Set only 1 email
$varName
$email
String with email, Array with email as key, name as value or email as value (without name)
$name
$throwMessage
CakeEmail
SocketException
_validateEmail( string $email )
Validate email address
$email
SocketException
_wrap( string $message , integer $wrapLength CakeEmail::LINE_LENGTH_MUST )
Wrap the message to follow the RFC 2822 - 2.1.1
$message
$wrapLength
optional CakeEmail::LINE_LENGTH_MUST addAttachments( string|array $attachments )
Add attachments
$attachments
CakeEmail
SocketException
addBcc( string|array $email , string $name null )
Add Bcc
$email
Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
addCc( string|array $email , string $name null )
Add Cc
$email
Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
addHeaders( array $headers )
Add header for the message
$headers
CakeEmail
SocketException
addTo( string|array $email , string $name null )
Add To
$email
Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
attachments( string|array $attachments null )
Add attachments to the email message
Attachments can be defined in a few forms depending on how much control you need:
Attach a single file:
$email->attachments('path/to/file');
Attach a file with a different filename:
$email->attachments(array('custom_name.txt' => 'path/to/file.txt'));
Attach a file and specify additional properties:
$email->attachments(array('custom_name.png' => array( 'file' => 'path/to/file', 'mimetype' => 'image/png', 'contentId' => 'abc123', 'contentDisposition' => false ));
Attach a file from string and specify additional properties:
$email->attachments(array('custom_name.png' => array( 'data' => file_get_contents('path/to/file'), 'mimetype' => 'image/png' ));
The contentId
key allows you to specify an inline attachment. In your email text, you can use <img src="cid:abc123" />
to display the image inline.
The contentDisposition
key allows you to disable the Content-Disposition
header, this can improve attachment compatibility with outlook email clients.
$attachments
optional null CakeEmail
SocketException
bcc( string|array $email null , string $name null )
Bcc
$email
optional null Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
cc( string|array $email null , string $name null )
Cc
$email
optional null Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
charset( string $charset null )
Charset setter/getter
$charset
optional null config( string|array $config null )
Configuration to use when send email
Load configuration from app/Config/email.php
:
$email->config('default');
Merge an array of configuration into the instance:
$email->config(array('to' => '[email protected]'));
$config
optional null CakeEmail
deliver( string|array $to null , string $subject null , string|array $message null , string|array $transportConfig 'fast' , boolean $send true )
Static method to fast create an instance of CakeEmail
$to
optional null $subject
optional null $message
optional null $transportConfig
optional 'fast' $send
optional true CakeEmail
SocketException
domain( string $domain null )
Domain as top level (the part after @)
$domain
optional null CakeEmail
emailFormat( string $format null )
Email format
$format
optional null CakeEmail
SocketException
emailPattern( string|boolean|null $regex false )
EmailPattern setter/getter
$regex
optional false The pattern to use for email address validation, null to unset the pattern and make use of filter_var() instead, false or nothing to return the current value
CakeEmail
from( string|array $email null , string $name null )
From
$email
optional null Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
SocketException
getHeaders( array $include array() )
Get list of headers
from
replyTo
readReceipt
returnPath
to
cc
bcc
subject
$include
optional array() headerCharset( string $charset null )
HeaderCharset setter/getter
$charset
optional null helpers( array $helpers null )
Helpers to be used in render
$helpers
optional null CakeEmail
message( string $type null )
Get generated message (used by transport classes)
$type
optional null messageId( boolean|string $message null )
Message-ID
$message
optional null CakeEmail
SocketException
readReceipt( string|array $email null , string $name null )
Read Receipt (Disposition-Notification-To header)
$email
optional null Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
SocketException
replyTo( string|array $email null , string $name null )
Reply-To
$email
optional null Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
SocketException
reset( )
Reset all CakeEmail internal variables to be able to send out a new email.
CakeEmail
returnPath( string|array $email null , string $name null )
Return Path
$email
optional null Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
SocketException
send( string|array $content null )
Send an email using the specified content, template and layout
$content
optional null SocketException
sender( string|array $email null , string $name null )
Sender
$email
optional null Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
SocketException
setHeaders( array $headers )
Sets headers for the message
$headers
CakeEmail
SocketException
subject( string $subject null )
Get/Set Subject.
$subject
optional null CakeEmail
template( boolean|string $template false , boolean|string $layout false )
Template and layout
$template
optional false $layout
optional false CakeEmail
theme( string $theme null )
Theme to use when rendering
$theme
optional null CakeEmail
to( string|array $email null , string $name null )
To
$email
optional null Null to get, String with email, Array with email as key, name as value or email as value (without name)
$name
optional null CakeEmail
transport( string $name null )
Transport name
$name
optional null CakeEmail
transportClass( )
Return the transport class
AbstractTransport
SocketException
viewRender( string $viewClass null )
View class for render
$viewClass
optional null CakeEmail
viewVars( array $viewVars null )
Variables to be set on render
$viewVars
optional null CakeEmail
protected string
The application wide charset, used to encode headers and body
null
protected array
List of files that should be attached to the email.
Only absolute paths
array()
protected 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()
protected 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()
protected array
Define Content-Type charset name
array( 'ISO-2022-JP-MS' => 'ISO-2022-JP' )
protected string
Domain for messageId generation. Needs to be manually set for CLI mailing as env('HTTP_HOST') is empty
null
protected array
Available formats to be sent.
array('text', 'html', 'both')
protected string
Regex for email validation
If null, filter_var() will be used. Use the emailPattern() method to set a custom pattern.'
self::EMAIL_PATTERN
protected array
Associative array of a user defined headers Keys will be prefixed 'X-' as per RFC2822 Section 4.7.5
array()
protected array
The mail that will be used in case of any errors like - Remote mailserver down - Remote user has exceeded his quota - Unknown user
array()
public string
Charset the email header is sent in If null, the $charset property will be used as default
null
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.9/class-CakeEmail.html