2015-06-25 82 views
1

我已經配置以下設置郵件發送但未被接收,笨

$config = Array(

     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.gmail.com', 
     'smtp_port' => 465, 
     'smtp_user' => '[email protected]', // change it to yours 
     'smtp_pass' => 'xyz', // change it to yours 
     'smtp_timeout'=>20, 
     'mailtype' => 'text', 
     'charset' => 'iso-8859-1', 
     'wordwrap' => TRUE 
     ); 

$this->load->library('email',$config); 
//$this->email->set_newline("\r\n"); 
$this->email->from('[email protected]', 'Garima'); 
$this->email->to('[email protected]'); 

// mail message here 

我得到以下信息:

Your message has been successfully sent using the following protocol: mail

From: "Garima" [email protected]

Return-Path: [email protected]

Reply-To: "[email protected]"

X-Sender: [email protected]

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <@gmail.com>

Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit

首先,如果我有定義的協議如SMTP,爲什麼它將協議顯示爲郵件。

其次,顯示的信息中沒有「to」字段。爲什麼這樣?我必須做什麼改變?

+0

您使用哪種類型的本地主機進行測試? xammp wamp等 – user4419336

+0

我正在使用xampp – GMehta

+0

另一件事是做一些時間codeigniter不會發送,除非發送電子郵件設置配置在xampp設置https://www.youtube.com/watch?v=TO7MfDcM-Ho – user4419336

回答

0

你忘了在你的代碼初始化電子郵件配置設置

$this->email->initialize($config); 

所以,你的代碼將

$this->load->library('email'); 
     $config = Array(
       'protocol' => 'smtp', 
       'smtp_host' => 'ssl://smtp.gmail.com', 
       'smtp_port' => 465, 
       'smtp_user' => '[email protected]', // change it to yours 
       'smtp_pass' => 'xyz', // change it to yours 
       'smtp_timeout'=>20, 
       'mailtype' => 'text', 
       'charset' => 'iso-8859-1', 
       'wordwrap' => TRUE 
       ); 

     $this->email->initialize($config);// add this line 

     //$this->email->set_newline("\r\n"); 
     $this->email->from('[email protected]', 'Garima'); 
     $this->email->to('[email protected]'); 
     $this->email->subject('Email Test'); 
     $this->email->message('Testing the email class.'); 
     $this->email->send(); 
     echo $this->email->print_debugger(); 
+0

Thankyou。這使我擺脫了上述問題,但現在它顯示了很多錯誤「fsockopen():無法連接」無法發送數據。 @Saty – GMehta

+0

聽起來不錯,你擺脫了你的問題!!現在什麼樣的錯誤你有請粘貼錯誤 – Saty

+0

的fsockopen():SSL操作失敗,代碼1. OpenSSL的錯誤信息:錯誤:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知協議 的fsockopen():失敗,使加密 的fsockopen( ):無法連接到ssl://smtp.gmail.com:587(未知錯誤) fwrite()期望參數1是資源,布爾給定 這樣的錯誤@Saty – GMehta

0

不要忘了裝載庫第一

$this->load->library('email'); 

然後配置這些設置Can Refer here too

$config = Array(
    'protocol' => 'smtp', 
    'smtp_host' => 'ssl://smtp.googlemail.com', 
    'smtp_port' => 465, 
    'smtp_user' => 'xxx',//your E-mail 
    'smtp_pass' => 'xxx',//Your password 
    'mailtype' => 'html', 
    'charset' => 'iso-8859-1' 
); 

$this->load->library('email', $config); 
$this->email->set_newline("\r\n"); 

// Set to, from, message, etc. 
$this->email->from('[email protected]', 'Your Name'); 
$this->email->to('[email protected]'); 
$this->email->cc('[email protected]'); 
$this->email->bcc('[email protected]'); 

$this->email->subject('Email Test'); 
$this->email->message('Testing the email class.'); 

$result = $this->email->send(); 

使用本地主機

  1. 發送郵件如果您正在使用XAMPP做到這一點。如果您正在使用WAMPStack Answer for Send mail with WAMP

要讀取發送郵件設置Stack Answer for Send mail with XAMPP

  • 更多關於CI的信息E-mail CI E-Mail Library

  • 相關問題