According to CI docs ( CodeIgniter Email Library ) ...
If you prefer not to set preferences using the above method, you can instead put them in a configuration file. Just create a new file called email.php, add the $ config array to this file. Then save the file in config / email.php and it will be used automatically. You will not need to use the function $ this-> email-> initialize () if you save your preferences in the configuration file.
I managed to get this to work by putting all the settings in the /config/email.php application .
$config['useragent'] = 'CodeIgniter'; $config['protocol'] = 'smtp'; //$config['mailpath'] = '/usr/sbin/sendmail'; $config['smtp_host'] = 'ssl://smtp.googlemail.com'; $config['smtp_user'] = 'YOUREMAILHERE@gmail.com'; $config['smtp_pass'] = 'YOURPASSWORDHERE'; $config['smtp_port'] = 465; $config['smtp_timeout'] = 5; $config['wordwrap'] = TRUE; $config['wrapchars'] = 76; $config['mailtype'] = 'html'; $config['charset'] = 'utf-8'; $config['validate'] = FALSE; $config['priority'] = 3; $config['crlf'] = "\r\n"; $config['newline'] = "\r\n"; $config['bcc_batch_mode'] = FALSE; $config['bcc_batch_size'] = 200;
Then in one of the controller methods, I have something like:
$this->load->library('email'); // Note: no $config param needed $this->email->from('YOUREMAILHERE@gmail.com', 'YOUREMAILHERE@gmail.com'); $this->email->to('SOMEEMAILHERE@gmail.com'); $this->email->subject('Test email from CI and Gmail'); $this->email->message('This is a test.'); $this->email->send();
Also, as Cerebro wrote, I had to uncomment this line in the php.ini file and restart PHP:
extension=php_openssl.dll
Luke May 28 '13 at 12:28 2013-05-28 00:28
source share