2016-06-26 20 views
0

CodeIgniterに問題があります。私は電子メール設定をプリロードしていますが、コントローラの機能を使って電子メールを送信しようとすると、エラー500が表示されます。助けてください!Codeigniterで電子メールを送信するとエラー500が表示される

public function regvalidation() 
{ 
    $this->load->library('form_validation'); 

    $this->form_validation->set_rules('email','email','required|trim|valid_email|is_unique[user_admin.username]'); 

    $this->form_validation->set_rules('password','Password','required|trim'); 
    $this->form_validation->set_rules('c_password','Confirm Password','required|trim|matches[password]'); 


    if ($this->form_validation->run()) 
    { 

     $this->load->library('email'); 
     $key = md5(uniqueid()); 

     //echo $this->input->post('email'); 

     $this->email->from('[email protected]','Edge Master'); 
     $this->email->to($this->input->post('email')); 
     $this->email->subject("EDGE | Confirm your account"); 

     $message = "<p>Thank you for signing up</p>"; 
     $message .= "<p><a href='".base_url()."main/register_user/".$key.">Click here</a>to confirm your account.</p>"; 

     $this->email->message($message); 

     $this->email->send(); 

     if ($this->email->send()) 
     { 
      echo "This email has been sent."; 
     } 
     else 
     { 
      echo "failed."; 
     } 
    } 

    else 
    { 
     $this->load->view('signup.php'); 
    } 
} 
+2

読むに最初email->send()を削除します。エラー。ログ、 –

+0

これらのログはどこにありますか? –

+0

@DeviantMark以下の答えを確認してください –

答えて

2

プロジェクトルートのindex.phpでENVIRONMENTを 'development'に設定し、エラーログを確認します。

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); 
switch (ENVIRONMENT) 
{ 
    case 'development': 
     error_reporting(-1); 
     ini_set('display_errors', 1); 
    break; 
... 
0

フォームの検証はhref属性

$message .= "<p><a href='".base_url()."main/register_user/".$key.">Click here</a>to confirm your account.</p>"; 
         ^          ^

if ($this->form_validation->run() == FALSE) 

欠落シングルクオートは

する必要がありますする必要があります
$message .= "<p><a href='".base_url()."main/register_user/".$key."'>Click here</a>to confirm your account.</p>"; 

メールコード

# remove this 
# $this->email->send(); 

if ($this->email->send()) 
{ 
    echo "This email has been sent."; 
} 
else 
{ 
    echo "failed."; 
} 
関連する問題