电子邮件不在codeigniter实时服务器中发送

时间:2017-10-31 11:18:38

标签: php codeigniter email

我是codeigniter的新手。 我的问题是电子邮件不是在实时服务器中发送。甚至没有发送文本邮件

    public function otpmail()
        {   
            $this->load->library('email');

            $config['protocol'] = 'mail';
                $config['mailtype'] = 'text';
                $config['mailpath'] = '';
                $config['charset'] = 'iso-8859-1';
                $config['crlf'] = '\r\n';
                $config['wordwrap'] = TRUE;
                $this->email->initialize($config);
                $baseurl = base_url();

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

       //print_r($username); echo $username[0]; exit;


          $from_email = "sales@varmanco.com"; 
                  $to_email = $this->input->post('email'); 

                 $content ="hi";



                $this->email->from($from_email, 'Varma & Co'); 
                $this->email->to($to_email);
                $this->email->subject('Enquiry From Website');                      
        $this->email->message($content);            
                        //$msg =  $this->email->send();



         if($this->email->send()) {
//echo "kk"; exit;
        $this->session->set_flashdata("yes","Thanks for contacting us");
        redirect($_SERVER['HTTP_REFERER']);

}
         else {
         print_r($this->email->print_debugger());         
    }
}

当我打印错误时显示

  •   
        

    无法使用PHP mail()发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。        User-Agent:CodeIgniter        日期:星期二,2017年10月31日11:22:56 +0000        来自:“Varma& Co”        返回路径:        回复:“sales@varmanco.com”        X-Sender:sales@varmanco.com        X-Mailer:CodeIgniter        X优先级:3(正常)        消息ID:< 59f85d104ec75@varmanco.com>        哑剧版:1.0        内容类型:text / plain;字符集= ISO-8859-1        内容传输编码:8位        =?ISO-8859-1 Q + Enquiry_From_Website?=        喜

      

1 个答案:

答案 0 :(得分:0)

试试这个:

>$config = array();             
>$config['smtp_user']    = 'Your username';
>$config['smtp_pass']    = 'Your Pass';         
>$config['protocol']    = 'smtp';
>$config['charset']     = 'utf-8';
>$config['smtp_port']    = 'The port your server uses for smtp';
>$config['smtp_host']    = 'Your mailing host address';
>$config['mailtype']    = 'html';
>$config['newline']      = "\r\n";
>$config['wordwrap']    = TRUE;
>$config['validate']    = TRUE;
>$config['dsn']         = TRUE;     
>$this->email->initialize($config);