-2

私を助けることができるすべての人、私は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.
    }
}


?>
4

2 に答える 2

0

メールが実際に何かを送信するかどうかを確認する必要があります。

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

レコードが保存されたことを確認しているだけです。詳細については、電子メール コンポーネントをデバッグ モードにすることもできます。

于 2013-01-04T01:39:17.373 に答える
0

たぶん遅くてうまくいきましたが、コンポーネント Email と Session を追加する必要があります

class ContactsController extends Controller {

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

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

…………

…………

…………

設定を確認し、/app/Config/email.php でテンプレートの使用を有効にします。

「デフォルト」設定では、実際のメールアドレスを入力して、正しく機能するかどうかをテストしてください!

于 2013-04-14T15:43:11.870 に答える