Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Send email in cakephp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 122
    Comment on it

    First create configuration file name as email.php inside app/config/email.php and setup different config options here.

    public $default = array(
        'transport' => 'Mail',
        'from' => array('fromname@email.com' => 'kshitiz dixit'),
        'charset' => 'utf-8',
        'headerCharset' => 'utf-8',
    );
    

    so it will set from name as kshitiz dixit and from email as froname@email.com. Next to use CakeEmail in our application need to load the clas using app::uses in our controller or model.

    App::uses('CakeEmail', 'Network/Email');
    

    Next is to create object of CakeEmail class.

    $Email = new CakeEmail();
    $Email->from(array('fromname@email.com' => 'kshitiz dixit'));
    $Email->to('abc@xyz.com', 'nameofrecipient');
    
    To set subject and email body,
    
    $Email->subject('my first cake email');
    $Email->send('hello');
    

    So send fucntion will send the email to recipient like this way we can send email in cakephp.

 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: