2013-09-03 3 views
16
public function sendemail(){ 
    $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]', 'Name'); 
    $this->email->to('[email protected]'); 
    $this->email->subject(' My mail through codeigniter from localhost '); 
    $this->email->message('Hello World…'); 
    if (!$this->email->send()) { 
    show_error($this->email->print_debugger()); } 
    else { 
    echo 'Your e-mail has been sent!'; 
    } 
} 

経由CodeIgniterのライブラリを使用して電子メールを送信しますか?は、私は電子メールを送信するためにCodeIgniterのを使用する場合、私はエラーを取得するlocalhostの

答えて

29

私の動作コードを確認してください。

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

     $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

ローカルホストには設定がありますので、メールを送信できますか? –

+0

ええ、ローカルホストでopensslを有効にする必要があります –

+0

なぜ毎回私が$ this-> email->('[email protected] ')を変更するのですか?ヤフーのような他のアドレスに、私はいつも「私」から送られた電子メールを、送信者の代わりに受け取りましたか? –

2

私は同じ問題を抱えており、postcast serverを使用して解決しました。ローカルにインストールして使用することができます。

関連する問題