每个可以帮助我的人,我是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.
}
}
?>
答案 0 :(得分:0)
您应该检查邮件是否实际发送了任何内容。
if ($this->Email->send($this->data['Contact']['message'])) {
// sent
} else {
// not sent
debug($this->Email);
exit;
}
您只是检查记录是否已保存。您还可以将电子邮件组件置于调试模式以获取更多详细信息。
答案 1 :(得分:0)
也许迟到了,你得到它,但你需要添加组件电子邮件和会话
class ContactsController extends Controller {
var $components = array('Email', 'Session');
function send() {
if(!empty($this->data)) {
$this->Contact->set($this->data);
.............
.............
.............
检查设置并启用模板的使用:/app/Config/email.php
在“默认”设置中,将您的真实电子邮件地址用于测试是否正常工作!