Код: Выделить всё
$this->load->library('email');
$config['charset'] = 'iso-8859-1';
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from('info@mysite.com', 'Scarabee');
$this->email->to('info@mysite.com');
$this->email->subject('Message via website');
$data['msg'] = nl2br($this->input->post('msg'));
$data['msg'] .= '
Verstuurd door:[/b]
';
if($this->input->post('bedrijf')){
$data['msg'] .= $this->input->post('bedrijf').'
';
}
$data['msg'] .= $this->input->post('naam').'
';
$data['msg'] .= $this->input->post('adres').' - '.$this->input->post('postcode').', '.$this->input->post('gemeente').'
';
$data['msg'] .= $this->input->post('tel').'
';
$data['msg'] .= $this->input->post('email');
$message = $this->load->view('email', $data, TRUE);
$this->email->message($message);
if($this->email->send()){
$success = 'Message has been sent';
$this->session->set_flashdata('msg', $success);
redirect('contact/'.$this->input->post('lang'));
}
else{
show_error('Email could not be sent.');
}
Обновить
Проблему выявила в функции внутри /system/libraries/Email.php (библиотека электронной почты CI по умолчанию). Комментирование кода внутри этой функции позволяет отправлять почту, а также правильно перенаправлять:
Код: Выделить всё
protected function _set_error_message($msg, $val = '')
{
$CI =& get_instance();
$CI->lang->load('email');
if (substr($msg, 0, 5) != 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5))))
{
$this->_debug_msg[] = str_replace('%s', $val, $msg)."
";
}
else
{
$this->_debug_msg[] = str_replace('%s', $val, $line)."
";
}
}
Подумайте...
ОБНОВЛЕНИЕ 2: РЕШЕНО
У меня было это в конструкции моего контроллера:
Код: Выделить всё
function __construct() {
parent::__construct();
$this->lang = $this->uri->segment(2, 'nl');
}
Решение: поменял $this->lang на $this->language, и всё отлично!
Думаю, я опубликую ответ здесь на случай, если кто-нибудь еще когда-нибудь потеряет волосы с подобной проблемой
Подробнее здесь: https://stackoverflow.com/questions/838 ... email-send
Мобильная версия