Невозможно отправить электронное письмо с помощью smtp PHP, возможно, ваш сервер не правильно настроен для использования этого метода отправки.
КОНТРОЛЛЕР
Код: Выделить всё
public function send()
{
$this->load->library('Recaptcha');
$this->load->library('email');
if( $this->input->is_ajax_request()){
$captcha_answer = $this->input->post('g-recaptcha-response');
$result = $this->validar($captcha_answer);
if ($result == 1) {
$mail = $this->input->post('contact_mail');
$name = $this->input->post('contact_name');
$msg = $this->input->post('contact_message');
$config = array(
'protocol' => 'smtp',
'smtp_host'=> 'ssl://smtp.googlemail.com',
'smtp_port'=> 465,
'smtp_user'=> '[email protected]',
'smtp_pass'=> '*********',
'mailtype'=> 'html',
'charset'=> 'utf-8',
'newline' => '\r\n'
);
$this->email->initialize($config);
$this->email->from($mail);
$this->email->to('[email protected]');
$this->email->from($mail);
$this->email->subject('IMPORTANTE-CORREO CONTACTO');
$this->email->message('PĂGINA NOVADERMA
'.$msg.'
');
if ($this->email->send()) {
echo json_encode('todo bien wacho');
}
}
else {
}
}
}
public function validar($captcha_answer)
{
$this->load->library('Recaptcha');
$response = $this->recaptcha->verifyResponse($captcha_answer);
if ($response['success']) {
return 1;
}
else {
return 0;
}
}
Подробнее здесь: https://stackoverflow.com/questions/418 ... send-email