[eluser]Unknown[/eluser]
I had somebody build me a site using PHP and Codeigniter framework.On the test server everything was working properly, but now, once the site is transfered on Justhost, email function doesnt work.At first i tought i didnt used the correct SMTP settings, but they are fine (support took a look).
Basically, owner can put his property on the site (like this:http://goo.gl/AZcrj), and when the visitor fills the contact form on the bottom, email is sent to owners email address, and the he can reply to the visitors email.
First time i used Justhost SMTP settings and tested it, email was sent.But from that point, till now, i always get an error when i try to send message via contact form.I even tried using Gmail SMTP settings, same thing happens :\
Here is the code (currently with Gmail SMTP), does anybody have any clue? Btw, im a PHP rookie, so i dont know much, but i did my best to explain.
Code:
public function send_mail($res)
{
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'aaaaaaaaaa';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html'; // or html
$this->email->initialize($config);
$this->email->from($res['sender_email'], $res['sender_name']);
$this->email->to($res['reciever']);
$this->email->reply_to($res['sender_email'], $res['sender_name']);
$this->email->subject('Email from site.');
$this->email->message($res['message']);
if($this->email->send()) {
return true;
} else {
return false;
}
//configure mail agent...
}
private function get_email_address($email)
{
$this->load->model('main_model');
$email = $this->main_model->get_email($email);
return $email;
}
public function get_email_message()
{
//only ajax requests are allowed
if(!$this->input->is_ajax_request()) {
die();
}
$res['message'] = $this->input->post('message');
$res['reciever'] = $this->input->post('receiver');
$res['sender_name'] = $this->input->post('sender_name');
$res['sender_email'] = $this->input->post('sender_email');
$res['reciever'] = $this->get_email_address($res['reciever']);
$res = $this->send_mail($res);
$this->output->set_content_type('application/json')->set_output(json_encode($res));
}