2014-12-04 92 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()); 
} 

调试

相关问题