0

I have a droplet on digital ocean which runs the LAMP server on digital ocean . I have hosted a site created in codeigniter on the digital ocean. I want to send email containing data from the forms on the site to my own email address. But some how the output for the code says data is showing 'sent' not a single email is being received in my gmail account . I have implemented same code on c-panel hosting but digitalocean is creating hurdles for me .

This is the code i have used to send email:

public function email()
{
   $from_email = "from@gmail.com"; 
   $to_email = $this->input->post('to@gmail.com'); 
   //Load email library 
   $this->load->library('email'); 
   $this->email->from($from_email, 'Parwati Hills'); 
   $this->email->to($to_email);
   $this->email->subject('Email Test'); 
   $this->email->message('Testing the email class.'); 
   //Send mail 
   if($this->email->send()) {
      print_r("Sent");
   }
   else {
      print_r("Not Sent");
   }
 }

The Link used for testing: https://parwatihills.com/index.php/Welcome/email

Output shows : Sent , But Email is not received. I have checked spam folder also. Help Needed.

  • Did you installed `sendmail`? Check [this article](https://www.digitalocean.com/community/questions/php-mail-function-enable). – brevis Sep 26 '18 at 13:55
  • yes send mail is alredy installed – pohankargaurang Sep 26 '18 at 14:01
  • Try to check mail log, maybe there you will find reason. – brevis Sep 26 '18 at 14:35
  • You are experiencing naming conflicts apparently (although it's hard to tell with no error information)... Your function's name (`email`) is the same as the mail library you're loading, so by using `$this->email` Codeigniter is basically not knowing what to do. You need to rename your function – Javier Larroulet Sep 27 '18 at 04:06
  • The other thing I noticed (but I wasn't going to fit in my previous comment) is that unless you're processing a form which actually has a field named `to@gmail.com` you are setting your `$to_email` variable with an empty value. `$this->input->post()` is used along with a field name to extract its value, not the other way around – Javier Larroulet Sep 27 '18 at 04:09
  • okay i will keep that in mind – pohankargaurang Sep 29 '18 at 14:29

0 Answers0