用户电子邮件中未发送电子邮件

时间:2015-10-03 10:05:40

标签: codeigniter

我的控制器

if (isset($_POST['send']))
{   

    $email = $this->input->post("email");

$reco=$this->ui_model->check($email);
    if($reco){
    foreach($reco as $row)
    if($row['email'])
     {  $username=$row['username'];
        $email=$row['email'];
        $password=$row['password'];

    $this->email->from('systron@micronix.com','Systron');
    $this->email->to($email);

    $this->email->subject('Email Test');
    $this->email->message('"Testing the email class.'); 

    $test=$this->email->send();




        echo"Request has been sent plz check your Email for password";
        $this->load->view('login_view.php');

     }

    }else
    {
       echo "Email id is not exist";
    $this->load->view('forget.php');
    }

我的模特

功能检查($ email)     {

$this->db->select('*');
$this->db->from('admin');
$this->db->where('email',$email);
$check=$this->db->get();
$res = $check->result_array();
return $res; 

}  

1 个答案:

答案 0 :(得分:1)

试试这个:

$config = Array(
                'protocol' => 'smtp',
                'smtp_host' => 'ssl://smtp.googlemail.com',
                'smtp_port' => 465,
                'smtp_user' => '',
                'smtp_pass' => '');

                $email=$row['email'];
                $msg='your message';
                $this->load->library('email', $config);
                $this->email->set_mailtype("html");
                $this->email->set_newline("\r\n");
                $this->email->from('from@gmail.com');
                $this->email->to('to@gmail.com');
                $this->email->subject('subject');
                $this->email->message($msg);
                if (!$this->email->send())
                {
                    show_error($this->email->print_debugger());
                }