2016-07-19 259 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

你可以清除如果可能将一个库调用到其他库吗? –