2011-10-29 30 views
0

我想弄清楚如何使用codeigniter发送电子邮件,并成功地使用我的Gmail帐户。在Codeigniter中用hotmail发送邮件?

但问题是,我不知道如何使用我的Hotmail帐户做...

继承人它使用的Gmail代码:

<?php 

class Email extends CI_Controller 
{ 
function index() 
{ 
     $config = array(
     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.googlemail.com', 
     'smtp_port' => 465, 
     'smtp_user' => '[email protected]', 
     'smtp_pass' => 'Password' 

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

    $this->email->from('[email protected]', 'Me'); 
    $this->email->to('AnotherGuy');  
    $this->email->subject('This is an email test');  
    $this->email->message('It is working. Great!'); 


    if($this->email->send()) 
    { 
     echo 'Your email was sent.'; 
    } 

    else 
    { 
     show_error($this->email->print_debugger()); 
    } 
} 

}

回答

0

使用类似代码,但如前所述,您需要更改smtp变量。 的Hotmail: 服务器:smtp.live.com 端口:587

尝试:

$config = array(
    'protocol' => 'smtp', 
    'smtp_host' => 'ssl://smtp.live.com', 
    'smtp_port' => 587, 
    'smtp_user' => '[email protected]', 
    'smtp_pass' => 'Password' 

); 

Source