我知道這種問題是典型的新手錯誤,我是一個新手。 我很困惑。一切似乎都對。任何人都可以請幫我指出我的語法錯誤在哪裏?cakephp2 CakeMail - 語法錯誤,意外';',期待')'
這裏是堆棧跟蹤說
CORE\Cake\Network\Email\CakeEmail.php line 362 → CakeEmail->config(string)
}
if ($config) {
$this->config($config);
} elseif (config('email') && class_exists($this->_configClass)) {
APP\Controller\ContactsController.php line 141 → CakeEmail->__construct(string)
}
}
$Email = new CakeEmail('smtp');
$Email->template('MassMail');
'smtp'
這裏是我這個頁面控制器看起來像
public function mail() {
$allCity = $this->City->find('all');
$this->set('city', $this->City->find('list'));
$this->set('cityall', $allCity);
if ($this->request->is('post')) {
$to = [];
$subject = $this->request->data['Emails']['judul'];
$content = $this->request->data['Emails']['content'];
$toList = $this->request->data["Emails"]["to"];
foreach ($toList as $kota) {
foreach ($allCity as $cityObj) {
if ($kota == $cityObj['City']['kota']) {
foreach ($cityObj['Contact']as $kontak) {
if ($kontak['email'] != "") {
array_push($to, $kontak['email']);
}
}
}
}
}
$Email = new CakeEmail('smtp'); //--> Line 141
$Email->template('MassMail');
$Email->emailFormat('html');
$Email->viewVars(['content' => $content]);
$Email->from(['[email protected]' => 'Forkom Jerman']);
$Email->to($to);
$Email->subject($subject);
$Email->replyTo('[email protected]');
$Email->transport('smtp');
if ($Email->send()) {
$this->Flash->set('Email Telah terkirim');
} else {
$this->Flash->set('Email tidak bisa terkirim');
};
}
}
,這裏是我的電子郵件配置
public $smtp = array(
'log' => true;
'transport' => 'smpt',
'from' => '[email protected]',
'host' => 'send.one.com',
'port' => 465,
'username' => 'forkom.****@gmail.com',
'password' => '*****!',
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
我已嘗試將smpt更改爲默認,或者甚至保留空白,以便它自動使用默認值($ Email = new CakeEmail();) 我甚至試過把剛纔複製從食譜粘貼代碼段直接看起來像這樣,只是爲了看看應該如何
$Email = new CakeEmail();
$Email->from(array('[email protected]' => 'My Site'));
$Email->to('[email protected]');
$Email->subject('About');
$Email->send('My message');
但語法錯誤消息仍然指出來:$電子郵件=新CakeEmail();
我也試着清除緩存TMP>緩存> presistent> myapp_cake_core_file_map
但仍nothng變化,
任何建議將是非常有益的。 謝謝!