0

Here is my code, i have tried for 12 hours but did not found solution. my email going to spam folder, it should go to inbox. can you correct it ?

problem can be in smtp details, this code was working fine on development server but when we shifted to client server and updated smtp then its showing problem of mail going to spam folder.

public function step4()
{
       parse_str(substr(strrchr($_SERVER['REQUEST_URI'], "?"), 1), $_GET);
       $data['trip'] = $this->input->xss_clean($_GET['trip']);
       $data['travel_date'] = $this->input->xss_clean($_GET['travel_date']);
       $data['origin_id'] = $this->input->xss_clean($_GET['origin_id']);
       $data['destination_id'] = $this->input->xss_clean($_GET['destination_id']);
       $data['origin'] = $this->input->xss_clean($_GET['origin']);
       $data['destination'] = $this->input->xss_clean($_GET['destination']);
       $fees = count(explode(',',substr($this->input->xss_clean($_GET['checkbox']),0,-1)));
       $data['price'] = $this->input->xss_clean($_GET['price']);
       $data['bus_id'] = $this->input->xss_clean($_GET['bus_id']);
       $data['timing'] = $this->input->xss_clean($_GET['timing']);
       $data['duration'] = $this->input->xss_clean($_GET['duration']);
       $data['kilometers'] = $this->input->xss_clean($_GET['kilometers']);
       $data['stops'] = $this->input->xss_clean($_GET['stops']);
       $data['route_id'] = $this->input->xss_clean($_GET['route_id']);
       $data['time_id'] = $this->input->xss_clean($_GET['time_id']);

       $data['checkbox'] = $this->input->xss_clean($_GET['checkbox']);
       // print_r(explode(',',substr($data['checkbox'],0,-1)));

       $data['name'] = $this->input->xss_clean($_GET['name']);
       $data['contact'] = $this->input->xss_clean($_GET['contact']);
       $data['email'] = $this->input->xss_clean($_GET['email']);
       $data['pickup_place'] = $this->input->xss_clean($_GET['pickup_place']);
       $data['session_id'] = $this->session->userdata('session_id');
       $data['ref_code'] = $this->input->xss_clean($_GET['ref_code']);
       if($this->input->xss_clean($_GET['trip'])=="Round Trip"){
            $data['return_date'] = $this->input->xss_clean($_GET['return_date']);
            $data['return_origin_id'] = $this->input->xss_clean($_GET['destination']);
            $data['return_destination_id'] = $this->input->xss_clean($_GET['origin']);
            $fee_return = count(explode(',',substr($this->input->xss_clean($_GET['checkbox_return']),0,-1)));
            $data['return_price'] = $this->input->xss_clean($_GET['return_price']);
            $data['return_bus_id'] = $this->input->xss_clean($_GET['return_bus_id']);
            $data['return_timing'] = $this->input->xss_clean($_GET['return_timing']);
            $data['return_duration'] = $this->input->xss_clean($_GET['return_duration']);
            $data['return_kilometers'] = $this->input->xss_clean($_GET['return_kilometers']);
            $data['return_stops'] = $this->input->xss_clean($_GET['return_stops']);
            $data['return_route_id'] = $this->input->xss_clean($_GET['return_route_id']);
            $data['return_time_id'] = $this->input->xss_clean($_GET['return_time_id']);

            $data['checkbox_return'] = $this->input->xss_clean($_GET['checkbox_return']);
            $data['total_price'] = $this->input->xss_clean($_GET['total_price']);
        }
        if($this->input->xss_clean($_GET['trip'])=="Round Trip"){
            $data['fee'] = count(explode(',',substr($data['checkbox'],0,-1))+explode(',',substr($data['checkbox_return'],0,-1)))*1;
        } else { 
            $data['fee'] =  count(explode(',',substr($data['checkbox'],0,-1)))*1;
        }

        $name=$this->input->xss_clean($_GET['name']);
        $email=$this->input->xss_clean($_GET['email']);  
        $pickup_place=$this->input->xss_clean($_GET['pickup_place']);  
        $contact=$this->input->xss_clean($_GET['contact']);
        $pickup_id=$data['pickup_place'][1];
        $data['step_four'] = $this->select_seat_model->insert_select_seat($name, $email,  $pickup_place,  $contact,  $data);
        $data['reservation'] = $this->select_seat_model->getReservation($route_id);
        $data['pickup'] = $this->select_seat_model->getPickupName($pickup_id);
        //$this->session->set_userdata($array);     

        $config['protocol'] = 'smtp';
        $config['smtp_host'] = 'localhost';
        $config['smtp_port'] = 25;
        $config['smtp_user'] = 'new_psdxpress@psdxpress.com';
        $config['smtp_pass'] = 'X52udnHGgD6P';
        $config['mailtype'] = 'html';
        $config['charset'] = 'iso-8859-1';
        $config['wordwrap'] = TRUE;
        // Load email library and passing configured values to email library 
        $this->load->library('email', $config);
        $this->email->set_newline("\r\n");
        // Sender email address
        $this->email->from('noreply@psdxpress.com', 'no reply');
        // Receiver email address
        $this->email->to('akramalibikaner@gmail.com',$this->input->post('email'));
        // Subject of email
        $this->email->subject('E-ticket');
        // Message in email
        $body = $this->load->view('e-ticket.php',$data,TRUE);
        $this->email->message($body);


        $ok = $this->email->send();


        if($ok=1) {
            $this->session->set_flashdata('msg','E-ticket sent on your mail'); 
            $this->load->view('step4.php');
        } else {
            $this->session->set_flashdata("msg","Error in sending Email."); 
            $this->load->view('dashboard');
        }

    }
  • Some sensible code indentation would be a good idea. It helps us read the code and more importantly it will help **you debug your code** [Take a quick look at a coding standard](http://www.php-fig.org/psr/psr-2/) for your own benefit. You may be asked to amend this code in a few weeks/months and you will thank me in the end. – RiggsFolly Nov 10 '16 at 16:56
  • This time i need solution, please don't down my question for your ranking – sajid mehmood Nov 10 '16 at 17:00
  • 1
    Nobody gets ranking points for downvoting, in fact it costs us ranking points to downvote. You get downvotes for bad questions – RiggsFolly Nov 10 '16 at 17:00
  • is this bad question? – sajid mehmood Nov 10 '16 at 17:03
  • If it's being marked as spam, then your code is good and the email is being sent successfully. It's your email that gmail doesn't like. There are several reasons why this could happen, which gmail outlines here: https://support.google.com/mail/answer/1366858?hl=en&expand=5 – aynber Nov 10 '16 at 17:04
  • If you google "analyze email for spam", there are several testers out there that could help explain why something would be marked as spam. I've never used them, so I cannot recommend any one site. – aynber Nov 10 '16 at 17:06

0 Answers0