2016-08-21 93 views
1

我正在嘗試基於用戶登錄獲得動態電子郵件配置。在config/mail.php中我嘗試過這樣。如何在cakephp中設置動態電子郵件配置

配置/ mail.php

public $default= array(
    "host" => Configure::read("mail_host"), 
    "port" => Configure::read("mail_port"), 
    "username" => Configure::read("mail_username"), 
    "password" => Configure::read("mail_password"), 
    "transport" => Configure::read("mail_transport") 
); 

但我得到錯誤

syntax error, unexpected '(', expecting ')' 

我曾經做過這樣的,但因爲我有大量的網頁我必須爲所有這樣做頁面。

$Email = new CakeEmail("default"); 
$Email->config(array(
     'host' => Configure::read('mail_host'), 
     'port' => Configure::read('mail_port'), 
     'username' => Configure::read('mail_username'), 
     'password' => Configure::read('mail_password'), 
     'transport' => Configure::read('mail_transport') 
    )); 

因此,我需要在mail.php中動態配置。有沒有可能,請提供一些解決方案。

+0

CakePHP的哪個版本您使用的? –

+0

我正在使用CakePHP 2.0 – Pravin

回答

相關問題