0

i am new in codeigniter what i am trying to do is fairly simple i am sending a mail using simple email library in code ignitor i have uploaded the code to the server but some how it is not sending the email! here's my code

constructor

 function __construct(){
        parent::__construct();
        $this->load->helper(array('form', 'url'));
        $this->load->model('contactus');
        $this->load->library('email');
    }

i have included the email library

 public function contactus()
    {
        $data = $this->input->post();
        $this->contactus->contactus_db($data);
        $this->email->to('uneeb@nextcrawl.com');
        $this->email->subject('Contact US');
        $msg="hey uneeb";
        $this->email->message($msg);
        if($this->email->send()) {
            echo "send";
        }
        else
        {
            echo "not send";
        }
        //redirect('Home');
    }

this is my email code i have done some validations that either mail is actually send or not and in this case it is showing send i don't know what is the issue!

Cœur
  • 37,241
  • 25
  • 195
  • 267
uneeb meer
  • 882
  • 1
  • 8
  • 21
  • Have you checked whether the `mail()` function is enabled on the server? Also a lot of the time mail sent via this function ends up in spam mailboxes or filtered out. – James Walker Mar 07 '17 at 14:54
  • how can we check that mail() function is enabled? and no i am not receiving email anywhere! btw my hosting is godaddy – uneeb meer Mar 07 '17 at 14:58
  • You can check [this resource](http://tutorialspage.com/php-check-if-mail-function-is-enabled-on-your-server/). I would reccomend not using the `mail()` function and using a transactional email service such as [Mailgun](https://www.mailgun.com/). Their free tier allows for 10k emails per month. – James Walker Mar 07 '17 at 15:03
  • ya i am using mailgun on other websites but there are many websites whom dont require much of a functionalities and also they are not dependent on emails so in these i tend to use simple mail functions and for other complex systems i use mail gun – uneeb meer Mar 07 '17 at 15:06
  • You don't have any Setting Email Preferences https://www.codeigniter.com/user_guide/libraries/email.html#setting-email-preferences –  Mar 07 '17 at 20:30
  • http://stackoverflow.com/questions/18586801/send-email-by-using-codeigniter-library-via-localhost –  Mar 07 '17 at 20:31
  • Also this tutorial is good https://www.youtube.com/watch?v=TO7MfDcM-Ho –  Mar 07 '17 at 20:36

0 Answers0