2014-12-04 61 views
1

我想從笨發送一封電子郵件,我的代碼是這樣的發送電子郵件導致空白頁

function sendMail(){ 
    $config = Array(
     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.googlemail.com', 
     'smtp_port' => 465, 
     'smtp_user' => '[email protected]', 
     'smtp_pass' => 'mypassword', 
     'mailtype' => 'html', 
     'charset' => 'iso-8859-1', 
     'wordwrap' => TRUE 
    ); 

    $message = 'test message'; 
    $this->load->library('email', $config); 
    $this->email->set_newline("\r\n"); 
    $this->email->from('[email protected]'); 
    $this->email->to('[email protected]'); 
    $this->email->subject('Test Message'); 
    $this->email->message($message); 
    if($this->email->send()){ 
     echo 'Email sent.'; 
    } 
    else 
    { 
     show_error($this->email->print_debugger()); 
    } 
} 

我已編輯php.ini並啓用opensll。但是,當我嘗試發送電子郵件時,我的代碼導致空白頁面,沒有成功消息或錯誤消息出現。我不知道該怎麼辦,任何線索?與SMTP主機

回答

0
$config = Array(
     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.gmail.com', 
     'smtp_port' => 465, 
     'smtp_user' => '[email protected]', 
     'smtp_pass' => 'password', 
     'mailtype' => 'html', 
    ); 
    $this->load->library('email', $config); 
    $this->email->set_newline("\r\n"); 

許多被錯誤試試這個

0

使用:的

$this->email->send() 
$this->email->print_debugger() 

代替:

if($this->email->send()){ 
    echo 'Email sent.'; 
} 
else 
{ 
    show_error($this->email->print_debugger()); 
} 

調試

相關問題