Welcome Guest, Not a member yet? Register   Sign In
Codeigniter email problem.
#1

[eluser]Unknown[/eluser]
I have an ajax function that passes on form input data to a function that passes the data to the database, loads a view and sends a success email.

This works perfectly locally but the problem is when its hosted, the 'process_confirm_submit' function doesn't execute properly. Everything submits to the database and the email gets sent but the view doesn't load and the ajax success doesn't run, even the echo "Test" doesn't work.

I've boiled it down to the the part sending the email causing the problem. If I comment it out the load view works.

Any help would be appreciated.

Here is the code.

Code:
function process_confirm_submit() {

  echo "Test";
  
  
   $info['first_name'] = $this->input->post('firstname');
   $info['last_name'] = $this->input->post('lastname');
   $info['email'] = $this->input->post('email');
   $info['country'] = $this->input->post('country');
   $info['address'] = $this->input->post('address');
   $info['city'] = $this->input->post('city');
   $info['postcode'] = $this->input->post('postcode');
   $info['embedcode'] = $this->input->post('videourl');
   $info['film_title'] = $this->input->post('filmtitle');

   $info['genre_id'] = $this->input->post('genre');
   $info['run_time'] = $this->input->post('runtime');
   $info['subtitles'] = $this->input->post('subtitles');
   $info['synopsis_short'] = $this->input->post('synopsis_short');
   $info['synopsis_long'] = $this->input->post('synopsis_long');
  
   $info['url_slug'] = $this->Select->makeUniqueSlug(url_title(trim($this->input->post('filmtitle')), "dash", TRUE), "submissions");
  
   // GET IMAGE FROM URL AND RESIZE
  
   if(!file_exists($this->root . "/media/uploads/submissionsimages/")) {
    mkdir($this->root . "/media/uploads/submissionsimages/");
    chmod($this->root . "/media/uploads/submissionsimages/", 0777);
   }
  
   if($this->input->post('vimeoimage') != "") {
  
    $hash = substr(hash('ripemd160', time()), 0, 5);
    
    $imageurl = $this->input->post('vimeoimage');
  
    $filename = substr($imageurl, strrpos($imageurl, '/') + 1);
  
    file_put_contents($this->root."/media/temp_uploads/".$filename, file_get_contents($imageurl));
    
    $sizes[] = Array(
     'width' => 205,
     'height' => 205,
     'prefix' => "box",
    );
    $sizes[] = Array(
     'width' => 81,
     'height' => 55,
     'prefix' => "thumbnail",
    );
    
    foreach($sizes AS $size) {
     $url = $this->root . "/media/temp_uploads/" . $filename;
     $newUrl = $this->root . "/media/uploads/submissionsimages/" . $size['prefix'] . "_" . $hash . $filename;
     $width = $size['width'];
     $height = $size['height'];
     createResizedImage($url, $newUrl, $width, $height);
     $resizedata['filename'] = $size['prefix'] . "_" . $filename;  
     $resizedata['filetype'] = $size['prefix'];
    }
    
    unlink($url);
    
    $info['image'] = $hash . $filename;
    
   }
      
   $this->Update->addRow('submissions', $info);
  
   $view = 'front/submit_form_success';
  
   $this->load->view($view, $data);
  
   // Email
   if($info['email']) {
    $config = Array(
     'mailtype' => 'html',
        'protocol' => 'sendmail',
        'smtp_host' => 'smtphost',
        'smtp_port' => 465,
        'smtp_user' => 'username@username',
        'smtp_pass' => '********'
    );
    
    $this->load->library('email', $config);
    $this->email->set_newline("\n");
    $this->email->from('username@username', 'subject');
    $this->email->to($info['email']);
    $this->email->subject('Successful Submission');
    
    $emaildata = Array(
     'first_name' => $info['first_name'],
     'last_name' => $info['last_name'],
     'film_title' => $info['film_title']
    );
    
    $html_email = $this->load->view('email/successful_submission', $emaildata, true);
    
    $this->email->message($html_email);
    
    $this->email->send();
   }
  

}




Theme © iAndrew 2016 - Forum software by © MyBB