Welcome Guest, Not a member yet? Register   Sign In
Cannot redirect after $this->email->send()
#1

[eluser]Unknown[/eluser]
Hi,

First post here, hope you can help me out. i have the following code which sends an email from a posted form:

Code:
$this->load->library('email');
   $config['charset'] = 'iso-8859-1';
   $config['mailtype'] = 'html';
   $this->email->initialize($config);

   $this->email->from('[email protected]', 'Scarabee');
   $this->email->to('[email protected]');
   $this->email->subject('Message via website');  
   $data['msg'] = nl2br($this->input->post('msg'));
   $data['msg'] .= '<br><br><b>Verstuurd door:</b><br>';
   if($this->input->post('bedrijf')){
    $data['msg'] .= $this->input->post('bedrijf').'<br>';
   }
   $data['msg'] .= $this->input->post('naam').'<br>';
   $data['msg'] .= $this->input->post('adres').' - '.$this->input->post('postcode').', '.$this->input->post('gemeente').'<br>';
   $data['msg'] .= $this->input->post('tel').'<br>';
   $data['msg'] .= $this->input->post('email');
   $message = $this->load->view('email', $data, TRUE);
   $this->email->message($message);
   if($this->email->send()){
    $success = $this->input->post('lang') == 'nl' ? 'Uw bericht werd verstuurd. We contacteren u zo snel mogelijk. Bedankt voor uw interesse in ons bedrijf.' : 'Votre message a &eacute;t&eacute; envoy&eacute;. Nous vous contacterons aussit&ocirc;t que possible. Merci de votre confiance en notre soci&eacute;t&eacute;.';
    $this->session->set_flashdata('msg', $success);
    redirect('contact/'.$this->input->post('lang'));
   }
   else{
    show_error('Email could not be sent.');
   }

Problem: the email gets sent with proper formatting (from the email view template), but the page then goes blank. For instance, if I try to echo out $message just below the $this->email->send() call, nothing shows up. Redirecting, as I'm attempting above, obviously doesn't work either.

I've been working with CI for years now, and am really stumped by this... Am I missing something? Thanks for any help...




Theme © iAndrew 2016 - Forum software by © MyBB