CakePHP 2.0: CakeEmail frustration

前端 未结 3 526
名媛妹妹
名媛妹妹 2021-01-05 21:31

In Cake 1.3, the EmailComponent did what it should do. The new Cake Email class in 2.0 turned out to be a frustration....No emails sent, No errors....vague documentation...<

相关标签:
3条回答
  • 2021-01-05 21:47

    I think you have to load your config from Config/email.php explicitly, it is not loaded automatically, not even the default config:

    $email = new CakeEmail();
    $email->config('default');
    
    //or in constructor::
    $email = new CakeEmail('default');
    
    0 讨论(0)
  • 2021-01-05 21:49

    This is my email config file . I didnt do any change here

    class EmailConfig {
    
        public $default = array(
            'transport' => 'Mail',
            'from' => 'Admin <no-reply@example.com>',       
            'charset' => 'utf-8',
            'headerCharset' => 'utf-8',
        );
    
    }
    

    This is how i send the mail

    $email    = new CakeEmail();
    
    $result   = $email->template('welcome')
                  ->emailFormat('text')
                  ->to($NewUser['email'])
                  ->from('admin@example.com')
                  ->send();
    var_dump($result);
    
    0 讨论(0)
  • 2021-01-05 21:55

    In my opinion you should use this:

    $email = new CakeEmail('gmail');
    
    0 讨论(0)
提交回复
热议问题