Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以cakephp联系形式发送电子邮件_Cakephp - Fatal编程技术网

以cakephp联系形式发送电子邮件

以cakephp联系形式发送电子邮件,cakephp,Cakephp,所有能帮助我的人,我是CakePHP新手,我对联系方式有问题,我遵循了本教程 但我的收件箱是空的: 我收到消息: 您的邮件已发送。谢谢,我们很快会给你回复。 但是,没有影响:。。 问题是什么 我的控制器: <?php class ContactsController extends AppController { var $components = array('Email'); var $helpers = array('Html', 'Form'); function

所有能帮助我的人,我是CakePHP新手,我对联系方式有问题,我遵循了本教程

但我的收件箱是空的: 我收到消息: 您的邮件已发送。谢谢,我们很快会给你回复。 但是,没有影响:。。 问题是什么

我的控制器:

<?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.
    }
}


?>

你应该检查邮件是否真的发送了任何东西

if ($this->Email->send($this->data['Contact']['message'])) {
    // sent
} else {
    // not sent
    debug($this->Email);
    exit;
}

您只是检查记录是否已保存。您还可以将电子邮件组件置于调试模式以了解更多详细信息。

可能到了很晚,但您需要添加电子邮件和会话组件

class ContactsController extends Controller {

var $components = array('Email', 'Session');

function send() {
    if(!empty($this->data)) {
        $this->Contact->set($this->data);

检查设置并启用:/app/Config/email.php中模板的使用


在“默认”设置中,测试您的真实电子邮件地址是否正常工作

检查你的垃圾邮件/垃圾文件夹LOLL;检查过了,但什么也没有;检查你的Apache?错误日志您的flash消息不依赖于实际发送的电子邮件-发送电子邮件可能会失败,并且会出现错误消息。谢谢,我现在会尝试。。没什么,$this->Email->send$this->data['Contact']['message']这是真的,我看不到电子邮件的调试。。。是否需要修改config/email.php.default??objectEmailComponent{to=>'dino@premium-assistance.com'from=>'JOHN COMPANY-我的名字是JOHN'replyTo=>null readreceive=>null return=>null cc=>array bcc=>array date=>null subject=>Website request'headers=>array additionalParams=>null layout=>default'template=>null lineFeed=>sendAs=>text'delivery=>mail'charset=>UTF-8'attachments=>array xMailer=>'CakePHP Email Component'filePathssmtpOptions=>array textMessage=>'TEST DATA OF MY MESSAGE TEST 1 2'htmlMessage=>null messageId=>true settings=>array components=>array\u header=>array\u MESSAGE=>array}