0

I am new to codeigniter. My issue is email is not sending in live server. not even text mail is sending

    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());         
    }
}

When i am printing the error it shows

  • Unable to send email using PHP mail(). Your server might not be configured to send mail using this method. User-Agent: CodeIgniter Date: Tue, 31 Oct 2017 11:22:56 +0000 From: "Varma & Co" Return-Path: Reply-To: "sales@varmanco.com" X-Sender: sales@varmanco.com X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <59f85d104ec75@varmanco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit =?iso-8859-1?Q?Enquiry_From_Website?= hi

  • "Your server might not be configured to send mail " seems to be the clue. Have you checked? – ADyson Oct 31 '17 at 11:25
  • Have you checked your config folder if it has email.php file and you need to change the `$config['protocol'] = 'smtp';` to `mail` there? – Shahroze Nawaz Oct 31 '17 at 11:32

1 Answers1

0

Try this :

>$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);
Sergiu Vintu
  • 47
  • 1
  • 5