CodeIgniter Forums
How to send email via Codeigniter? I'm using NameCheap's Open-Xchange server.. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: How to send email via Codeigniter? I'm using NameCheap's Open-Xchange server.. (/showthread.php?tid=57807)



How to send email via Codeigniter? I'm using NameCheap's Open-Xchange server.. - El Forum - 04-12-2013

[eluser]Unknown[/eluser]
Hello,

I want to send an email if the user forgot his password. But it is not sending using my code:

Code:
function _send_email($type, $email, &$data)
{
  $this->load->library('email');
  $this->email->from($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
  $this->email->reply_to($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
  $this->email->to($email);
  $this->email->subject(sprintf($this->lang->line('auth_subject_'.$type), $this->config->item('website_name', 'tank_auth')));
  $this->email->message($this->load->view('email/'.$type.'-html', $data, TRUE));
  $this->email->set_alt_message($this->load->view('email/'.$type.'-txt', $data, TRUE));
  $this->email->send();
}

What else do I need to set up to make this work?


How to send email via Codeigniter? I'm using NameCheap's Open-Xchange server.. - El Forum - 04-15-2013

[eluser]XMadMax[/eluser]
Hey alcatraz, you must to define email.php in the config file, with smtp protocolo, port user and password used to connect your remote mail server.

http://ellislab.com/codeigniter/user-guide/libraries/email.html

Example of email.php file ussing google account:

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '10';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'mygooglepassword';