每个可以帮助我的人,我是 CakePHP 的新手,我的联系表格有问题,我按照本教程http://blog.jandorsman.com/2011/05/cakephp-contact-form-with-validation-rules/
但是我的收件箱是空的 :( 我收到了消息:您的消息已发送。谢谢,我们会尽快回复您。但是,没有效果 :(.. 有什么问题?
我的控制器:
<?php
class ContactsController extends AppController {
var $components = array('Email');
var $helpers = array('Html', 'Form');
function send() {
if(!empty($this->data)) {
$this->Contact->set($this->data);
if($this->Contact->validates()) {
if(!empty($this->data['Contact']['company'])) {
$this->Email->from = $this->data['Contact']['company'] . ' - ' . $this->data['Contact']['name'] . ' <' . $this->data['Contact']['email'] . '>';
} else {
$this->Email->from = $this->data['Contact']['name'] . ' <' . $this->data['Contact']['email'] . '>';
}
$this->Email->to = 'info@mycompany.com';
$this->Email->subject = 'Website request';
$this->Email->send($this->data['Contact']['message']);
$this->Session->setFlash('Your message has been sent.');
// Display the success.ctp page instead of the form again
$this->render('success');
} else {
$this->render('index');
}
}
}
public function index() {
// Placeholder for index. No actual action here, everything is submitted to the send function.
}
}
?>