Codeigniter电子邮件发送但未收到

时间:2018-03-02 20:03:01

标签: codeigniter codeigniter-3

我正在使用CodeIgniter发送电子邮件,向我显示成功消息“您的电子邮件发送成功”但我没有在我的帐户上收到电子邮件。这是一个服务器问题,我坚持这个问题很多天。

        $name       = post('name');
        $from_email = post('from_email');
        $to         = post('to');
        $subject    = post('subject');
        $msg        = post('msg');


        $this->load->library('email');

        $this->email->from($from_email, $name);
        $this->email->to($to);

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

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

        if ($result) 
        {
            $msg = "Your Email Send is Successfully";
            $this->session->set_flashdata('success',$msg);
            redirect('users','refresh');
        }
        else
        {
            $msg = "Error! Can not Send Email";
            $this->session->set_flashdata('error', $msg);
            redirect('users','refresh');
        }

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

public function send_mail(){
    $this->load->library('email');
    $to_email = 'abc@gmail.com';
    $from_email = 'xyz@gmail.com';

    $config = array(
                    'charset' => 'utf-8',
                    'wordwrap' => TRUE,
                    'mailtype' => 'html'
                );

    $this->email->initialize($config);

     $this->email->from($from_email);
                $this->email->to($to_email);
                $this->email->subject('Test mail send');
                $this->email->message('Test Mail);

    if($this->email->send()){
    echo "send";
    }else{
    echo "error";
    }
}