使用cakephp 1.3发送电子邮件

时间:2014-01-22 09:08:17

标签: email cakephp-1.3

我正在使用此参考的代码 http://books.google.com.ph/books?id=oXpiVSW5jqkC&pg=PT576&lpg=PT576&dq=app/views/elements/email/html&source=bl&ots=hAf3uDnVRb&sig=rrlbwekcKWfKhvmCvlYdFqC4EHQ&hl=en&sa=X&ei=dVnfUpbdB_GziQfSh4HgCA&ved=0CDAQ6AEwAQ#v=onepage&q=app%2Fviews%2Felements%2Femail%2Fhtml&f=false

我在我的电子邮件控制器中的appanetroller中编写了代码 <

lass EmailsController扩展了AppController {

public $components = array(
    'Email' =>array(
    'delivery' => 'smpt',
    'smtpOptions' => array(
    'host' =>
    'ssl://smtp.gmail.com',
    'port' => 465,
    'username' => 'redbaloons@gmail.com',
    'password' => '123456789'
    )
    )
    );

然后我跟着这个控制器索引() var $ name ='电子邮件';

function index() {
    $this->Email->recursive = 0;
    $this->set('emails', $this->paginate());
    $this->Email->to = 'Destination<redbaloons@gmail.com>';
    $this->Email->subject = 'Testing The Email component';
    $sent('Hello World');
    if(!$sent) {
        echo 'ERROR: ' . $this->Email->smtpError . '<br />';
    }else{
        echo 'Email sent!';
}

然后只是测试它,然后我得到了这个错误 致命错误:函数名称必须是第24行的C:\ xampp \ htdocs \ reservation \ controllers \ emails_controller.php中的字符串

任何配置只是为了测试这个?请帮忙......

1 个答案:

答案 0 :(得分:0)

此行中的语法错误:

$sent('Hello World');

我不确切知道你应该使用什么,但它应该是这样的:

$sent = $this->Email->send("Hello World");