0

I am developing an e-commerce system. My e-commerce system is up in my hosting called zoom. I am done in the part of ordering and right now, I'm having difficulty in sending the email.

It is working but it goes in the spam folder instead of inbox.

NOTE: I already created an email account in my hosting zoom and I used it in my code(you can see below)

Question: I want to send the email without being labeled as spam. Is there something missing or wrong in my code? Please point me towards right direction.

Controller

 public function process()
    {         
        $id = $this->session->userdata('id');
        $where = array('id' => $id);
        $get_orders  = $this->Crud_model->join_orders_customer('*','orders',$id);
        $get_invoice = $this->Crud_model->get_invoice('*','orders',$id);

        $email = $this->Crud_model->get_email($id);

        $config = array(
                    'smtp_timeout' => '4',
                    'charset' => 'utf-8',
                    'mailtype'=> 'html'
                    );
                    $this->load->initialize($config);
                    $fromemail="zeesdelivery@zessdelivery.com";
                    $to = $email->email_address;
                    $subject = "Your Order is not Processing";
                    foreach($get_orders as $row){
                     $mesg = "<h1>Schedule Accepted!!!</h1> 

                            <h3>Thank you for trusting and using Exclure Pest Control. $row->product_name</h3> 
                            <h3>Your reserve inspection is accepted. We sure to call you as soon as possible</h3>
                            <p>--------------------------------------------------------------------------------------</p>
                            <h4>For more details contact us at,</h4>
                            <h4>Exclure Pest Control</h4>    
                            <h4>Email : exclure@exclure.com.ph</h4>
                            <h4>Contact Number: 525-5399/ 498-1626 </h4>              
                            <h4>Facebook : https://web.facebook.com/ExclurePestControl/</h4>";
                    }

                   $this->load->library('email');
                    $this->email->clear();
                    $this->email->from($fromemail, 'Zees Delivery');
                    $this->email->to($to);
                    $this->email->set_header('Header1', 'Value1');
                    $this->email->set_newline("\n");
                    $this->email->subject($subject);
                    $this->email->message($mesg);
                    $this->email->set_mailtype('html');
                    $this->email->send();
                    $this->cart->destroy();
                    echo json_encode("success");
            }
Shahbaz A.
  • 4,047
  • 4
  • 34
  • 55
Angel
  • 966
  • 4
  • 25
  • 60
  • The syntax error doesn't explain why the email ends up in the spam folder. This has more to do with emailing than with any code. Take a look at things like SPF, DKIM and the like. – KIKO Software Oct 03 '17 at 08:47
  • This is mostly due to the `server` not `code`. Try using some email provider service for this. – mega6382 Oct 03 '17 at 08:48
  • For an e-commerce system you could use an external service like: https://postmarkapp.com No advertisement, I use it, and like it. There are alternatives. – KIKO Software Oct 03 '17 at 08:50
  • I tried your suggestion @KIKOSoftware, I already created an account. – Angel Oct 03 '17 at 09:21
  • Possibly it is because of your hosting account.Try mailgun or some other clients to send emails. – Rajeev Radhakrishnan Oct 03 '17 at 09:26

1 Answers1

1

I am assuming you are checking in gmail where the email is flagged as spam.

Email clients/servers flag emails as spam based on the content and domain names.

There should not be any technical reason for the email to land in spam folder, the reason is more to do with content and email address domain.

Subir Kumar Sao
  • 8,171
  • 3
  • 26
  • 47
  • 1
    I think this answer is quite vague, and slightly wrong. There probably are 'technical reasons', and spam filters don't look at the content as often as you might think. Can you be more specific? You would have been right 10 years ago... but things have progressed since then. – KIKO Software Oct 03 '17 at 08:54