2012-05-03 64 views
0

我收到了用於發送基本電子郵件的代碼。但對於SMTP,我不能完善這個:使用cakephp通過smtp發送電子郵件

 function send(){ 

      $this->Email->smtpOptions = array(
       'port'=>'465', 
       'timeout'=>'30', 
       'host' => 'ssl://smtp.gmail.com', 
       'username'=>'[email protected]', 
       'password'=>'mypassword', 
      ); 

     $this->Email->delivery='smtp'; 

      $this->Email->send = 'debug'; 

      $this->Email->to = '[email protected]'; 
     $this->Email->subject = 'hurrah'; 
//  $this->Email->replyTo = '[email protected]'; 
     $this->Email->from = 'Charmaine Khay Sorila<[email protected]>'; 
     //$this->Email->send('Here is the body of the email Chams Email Test'); 
     //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()) { 
      $this->Session->setFlash('Simple email sent'); 
     } else { 
      $this->Session->setFlash('Simple email not sent'); 
      $this->set('smtp_errors', $this->Email->smtpError); 
     } 
     } 

    } 

我得到這個工作,而不$這個 - >的電子郵件 - >快遞=「SMTP」;但是當我加入這一行,沒有電子郵件,可以在所有發送:(

+0

您正在使用調試選項,嘗試將其刪除 – yossi

+0

同樣的事情yossi ..實際發生的是頁面加載了幾秒鐘,然後它不會發送任何電子郵件... :( – Charmie

+0

第一:你得到了什麼錯誤? – yossi

回答

0

如果你不希望實際發送電子郵件,而是想測試出來的功能,你可以使用下面的發送選項:

Copy to Clipboard 
$this->Email->delivery = 'debug'; 
+0

那裏。我得到它的工作,但事情是..我檢查,如果它真的是用於傳遞我的郵件,所以我故意鍵入的密碼錯誤,但它仍然發送了一封電子郵件的SMTP ...「。 – Charmie

相關問題