【问题标题】:Codeigniter email send but not receivedCodeigniter 电子邮件发送但未收到
【发布时间】:2018-03-02 20:03:01
【问题描述】:

我正在使用 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');
        }

【问题讨论】:

  • 你有 post('from_email') 但我应该是$this->input->post('from_email')
  • 你应该使用 $_POST['from_email'] 或$this->input->post('from_email')

标签: codeigniter codeigniter-3


【解决方案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";
        }
}

【讨论】:

  • 它显示发送但未收到电子邮件。
猜你喜欢
  • 2014-03-12
  • 2017-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-22
  • 2015-09-11
  • 2014-07-20
  • 1970-01-01
相关资源
最近更新 更多