Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • CakeEmail

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 512
    Comment on it

    CakeEmail

    class CakeEmail(mixed $config = null)

    CakeEmail is a new class introduce to send email. With the help of this class one can send email from any where in the application.The CakeEmail class replaces the earlier used EmailComponent and provides more flexibility in sending emails.

    The class is loaded using App::uses(): App::uses('CakeEmail', 'Network/Email');

    We can use CakeEmail in the similar way as we use EmailComponent.But instead of using attributes in the CakeEmail class we use methods.

    Example:

    $Email = new CakeEmail();
    $Email->from(array('XYZ@example.com' => 'Example'))
        ->to('ABC@example.com')
        ->subject(Explaination)
        ->send('My example explaination);

    One can also choose sender with the sender() method i.e.

    $Email = new CakeEmail();
    $Email->sender('XYZ@example.com', 'I choose sender');

    Configuration:

    First create the file email.php under directory app/Config/ with the class name EmailConfig. The example of this file is stored in app/Config/email.php.default.
    CakeEmail class will then create an instance of the EmailConfig class to access the configuration . You can use the constructor to do that:

    class EmailConfig {
        public function __construct() {
            // Do conditional assignments here.
        }}
    

    Configuration Keys list which are used is as following : The following configuration keys are used:

    1. 'from': Email or array of sender. See CakeEmail::from().

    2.'sender': Email or array of real sender. See CakeEmail::sender().

    3.'to': Email or array of destination. See CakeEmail::to().

    4.'cc': Email or array of carbon copy. See CakeEmail::cc().

    5.'bcc': Email or array of blind carbon copy. See CakeEmail::bcc().

    6.'replyTo': Email or array to reply the e-mail. See CakeEmail::replyTo().

    7.'readReceipt': Email address or an array of addresses to receive the receipt of read. See CakeEmail::readReceipt().

    8.'returnPath': Email address or and array of addresses to return if have some error. See CakeEmail::returnPath().

    9.'messageId': Message ID of e-mail. See CakeEmail::messageId().

    10.'subject': Subject of the message. See CakeEmail::subject().

    11.'message': Content of message. Do not set this field if you are using rendered content.

    12.'headers': Headers to be included. See CakeEmail::setHeaders().

    13.'viewRender': If you are using rendered content, set the view class name. See CakeEmail::viewRender().

    14.'template': If you are using rendered content, set the template name. See CakeEmail::template().

    15.'theme': Theme used when rendering template. See CakeEmail::theme().

    16.'layout': If you are using rendered content, set the layout to render. If you want to render a template without layout, set this field to null. See CakeEmail::template().

    17.'viewVars': If you are using rendered content, set the array with variables to be used in the view. See CakeEmail::viewVars().

    18.'attachments': List of files to attach. See CakeEmail::attachments().

    19.'emailFormat': Format of email (html, text or both). See CakeEmail::emailFormat().

    20.'transport': Transport name. See CakeEmail::transport().

    21.'log': Log level to log the email headers and message. true will use LOG_DEBUG. See also CakeLog::write()

    22.'helpers': Array of helpers used in the email template.

    All of above listed configurations are optional, except 'from'. If you want to put more configurations in the array, the configurations will be used in the CakeEmail::config() method and passed to the class config().

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: