2014-11-14 153 views
0

我試圖用這個代碼笨電子郵件後成功發送

$config = array(
     'protocol' => 'smtp', 
     'smtp_host' => 'localhost', 
     'smtp_port' => 465, 
     'smtp_user' => '[email protected]', 
     'smtp_pass' => 'password', 
     'mailtype' => 'html', 
     'mailpath' => '/usr/sbin/sendmail', 
     'charset' => 'iso-8859-1', 
     'wordwrap' => TRUE 
    ); 
    $this->load->library('email', $config); 

    $message = ''; 
    $this->load->library('email', $config); 
    $this->email->set_newline("\r\n"); 
    $this->email->from('[email protected]'); // change it to yours 
    $this->email->to('[email protected]'); // change it to yours 
    $this->email->subject('Resume from JobsBuddy for your Job posting'); 
    $this->email->message($message); 
    if ($this->email->send()) { 
     echo 'Email sent.'; 
    } else { 
     show_error($this->email->print_debugger()); 
    } 

在發送,但收件箱,垃圾郵件,垃圾沒有發現這一情況的電子郵件。 請幫助我。謝謝你

回答

0

你不能發送電子郵件作爲[email protected]你的本地主機。您的電子郵件可能會被列入黑名單,因爲您的本地SMTP不是gmail.com。你應該使用Gmail的SMTP。

0

由於您嘗試使用本地主機,因此電子郵件及其內容未經過身份驗證。 使用SMTP谷歌主機。

$config = Array(
    'protocol' => 'smtp', 
    'smtp_host' => 'ssl://smtp:googlemail.com', 
    'smtp_port' => 465, 
    'smtp_user' => '[email protected]', 
    'smtp_password' => 'mypassword', 
); 

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

$this->email->from('[email protected]', 'FirstName LastName'); 
$this->email->to('[email protected]'); 
$this->email->subject('subject test'); 
$this->email->message('this is the body'); 

if($this->email->send()) 
{ 
    echo 'mail sent'; 
} 

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