2016-07-19 155 views
1

不發在我的項目我在現場發送的電子郵件,但其顯示SMTP電子郵件活

public function send_mail($to_email, $mail_subject, $mail_message, $attachment='') 
{ 

    $msg_body=' 
      <!DOCTYPE html> 
      <html> 
      <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
      <title>Test</title> 
      </head> 
      <body> 
      <table width="80%" border="0" style="" cellspacing="0" cellpadding="0" align="center"> 
      </table></body></html>'; 
    $config['protocol'] = 'smtp'; 
    $config['smtp_host'] = 'ssl://smtp.gmail.com'; 
    $config['smtp_port'] = '465'; 
    $config['smtp_timeout'] = '7'; 
    $config['smtp_user'] = '[email protected]'; 
    $config['smtp_pass'] = '[email protected]@'; 
    $config['charset'] = 'utf-8'; 
    $config['newline'] = "\r\n"; 
    $config['mailtype'] = 'html'; // or html 
    $config['validation'] = TRUE; // bool whether to validate email or not 
    $this->email->initialize($config); 
    $this->email->from('[email protected]', 'www.test.com'); 
    $this->email->subject('Email Test'); 
    $this->email->message('Testing the email class.'); 
    $this->email->send(); 
    echo $this->email->print_debugger(); 
    exit; 
} 

我有這樣的

致命錯誤一個錯誤的問題:調用一個成員函數初始化()在/ 非對象我初始化工作正常。它在我的本地服務器上工作正常。

   <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"> 

      <h4>A PHP Error was encountered</h4> 

      <p>Severity: Notice</p> 
      <p>Message: Undefined property: airport_mailer::$email</p> 
      <p>Filename: libraries/airport_mailer.php</p> 
      <p>Line Number: 109</p> 

      </div><br /> 
      <b>Fatal error</b>: Call to a member function initialize() on a non-object in <b>/home/goairport/public_html 
      /application/libraries/airport_mailer.php</b> on line <b>109</b><br /> 
+0

你有沒有加載郵件服務器 –

+0

後完整的錯誤就在這裏 –

+0

可你這'致命錯誤的例子斯巴達 –

回答

0

我想你錯過了加載email library。只需在$this->email->initialize($config);之前添加此行即可加載您的email library

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

另請參見:CodeIgniter Sending Email

+0

我補充說你可以發送電子郵件庫文件 –

+0

它是在建。 – Ali

+0

你可以清除如果可能將一個庫調用到其他庫嗎? –