2012-05-03 2 views
0

테스트 메일을 보낼 수 없기 때문에 cakephp에서 이메일을 디버깅하려고합니다. 그러나, 내가하는 모든 것은 저에게 빈 웹 페이지, 심지어 디버그를 제공합니다.cakephp에서 디버깅 전자 메일이 작동하지 않습니다.

C : 나는 이미 다음은 내 코드는 2로 디버그 모드를 설정 \ XAMPP \ : \ XAMPP \ htdocs를 \ NewFolder \ 응용 프로그램 \ 웹 루트 \ 응용 프로그램 \ controllersmailer_controller.php

<?php 
class MailerController extends AppController { 

    var $name = 'Mailer'; 
    //Not using a model 
    var $uses = ''; 
    //The built in Cake Mailer 
    var $components = array('Email'); 

    $this->Email->delivery = 'debug'; 
    /** 
    * Send a text string as email body 
    */ 
    function sendSimpleMail() { 
     //$this->Email->to = '[email protected]'; 
     $this->Email->to = '[email protected]'; 
     $this->Email->subject = 'Cake test simple email'; 
     $this->Email->replyTo = '[email protected]'; 
     $this->Email->from = 'Cake Test Account <[email protected]>'; 
     //Set the body of the mail as we send it. 
     //Note: the text can be an array, each element will appear as a 
     //seperate line in the message body. 
     if ($this->Email->send('Here is the body of the email')) { 
      $this->Session->setFlash('Simple email sent'); 
     } else { 
      $this->Session->setFlash('Simple email not sent'); 
     } 
     //$this->redirect('/'); 
     $this->Email->delivery = 'debug'; 

    } 
} 
?> 

C 이메일 \ htdocs를 \ NewFolder \ 응용 프로그램 \ 웹 루트 이메일 \ 응용 프로그램 \ 전망 \ 레이아웃 \ \ default.ctp

<?php echo $this->Session->flash(); ?> 
<?php echo $this->Session->flash('email'); ?> 

C : \ XAMPP \ htdocs를 \ NewFolder \ 응용 프로그램 \ 웹 루트 \ 이메일 \ 응용 프로그램 \ 전망 \ 레이아웃 \ 메일 \ HTML \ default.ctp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<html> 
<body> 
<?php echo $content_for_layout; ?> 
<?php echo $this->Session->flash(); ?> 
<?php echo $this->Session->flash('email'); ?> 
</body> 
</html> 

C : 로컬이 응용 프로그램을 실행하는 경우 \ XAMPP \ htdocs를 \ NewFolder \ 응용 프로그램 \ 웹 루트 이메일 \ 응용 프로그램 \ 전망 \ 레이아웃 \ 이메일 \ 텍스트 \의 default.ctp

<?php echo $content_for_layout; ?> 

답변

0

\, 나는 당신이 필요로 생각 메일 서버가 작동하도록 설정하십시오. 그렇지 않으면 공급자와 함께 smtp 메일 옵션을 사용할 수 있습니다. 이를 위해서는 메일 설정을 구성해야합니다. 에서

당신의 app\config 당신은 당신이 설정은 이메일을 보내 다음 코드를 사용할 수있는 컨트롤러에이 후 파일 email.php

<?php 
    class EmailConfig { 

     public $default = array(
      'host' => 'ssl://smtp.gmail.com', 
      'port' => 465, 
      'username' => 'your email address', //[email protected] 
      'password' => 'password', 
      'transport' => 'Smtp', 
      'from' => array('From Email Address' => 'Name to be displayed in the Email'), 
      'log' => true 
     ); 

    } 

을 만들 수 있습니다. 접근 SMTP 서버를 필요로하는 것보다 다른

$email = new CakeEmail(); 
$email->to('[email protected]'); 
$email->subject('Email testing Subject');  
$email->send('Email testing content'); 
+0

gvLearner,이 줄은 무엇을합니까? $ email = new CakeEmail(); – Charmie

+0

cakephp에 내장 된 기능입니까? – Charmie

+0

및 포트는 항상 465입니까? – Charmie

0

, 당신은 또한

$this->Email->delivery = 'debug'; // needs to be *inside* a function 

이 또한주의 ... 함수의 외부에서이 문을 배치 할 수 없습니다이 명령 사용을 때, 그것은 것 단지 이메일을 세션 변수에 저장하고 가 아닌을 보내면됩니다.

관련 문제