I am trying to insert the name, email, company, phone and country from the array into the email message, but all I get is an empty email. The subject, to and from all works, but I am not getting the message in the email. Can anyone tell me what I am doing wrong?
<? php
public function contact_mail() {
$data = array(
'name' => $this->input->post('name'),
'email' => $this->input->post('email'),
'company' => $this->input->post('company'),
'phone' => $this->input->post('phone'),
'country' => $this->input->post('country')
);
$success = $this->data->save_contact_info($data);
if ($success) {
$data = array('success_message' => 'Thank you. We\'ll be in touch.');
$this->load->view('ajax/json', array('json' => $data));
$this->load->library('email');
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from("noreply@example.com", "Example Notification Service");
$this->email->to(array('mha@example.com'));
$this->email->subject('Contact form');
$this->email->message($data);
$this->email->send();
}
else {
$this->load->view('ajax/error', array('error_msg' => 'Please fill out all fields.'));
}
}
?>