I am in the process of setting up ion auth and want to be able to send activation emails. They fail to send.
So I attempted to just send a basic email in codeigniter to make sure things are working and that is failing also.
for testing purposes I re downloaded a fresh CI folder and changed the default controller in routes to my controller.
$routes['default_controller']='Email';
My Controller
<?php
class Email extends CI_Controller{
public function index(){
$data['title']='sent';
$this->load->view('sending_email',$data);
}
public function send(){
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('[email protected]', 'phpnoob');
$this->email->to('[email protected]');
$this->email->subject('Hey');
$this->email->message('Testing the email');
$this->email->send();
echo "this email is sent";
}
}
?>
In my config folder I made a file called email also to load configurations.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config['protocol']='smtp';
$config['smtp_host']='ssl://smtp.googlemail.com';
$config['smtp_port']=465;
$config['smtp_user']='[email protected]';
$config['smtp_pass']='XXPASSXX';
$config['mailtype']= 'html';
$config['priority']=4;
$config['charset']='utf-8';
?>
Now I notice that when I try to remove the index function I cannot load the controller at all. I do not know why. Even if I try to call the controller and method I get a 404 error.
Also this is not on my localhost and I have a live server since mail never seems to work on localhost.
Make sure that Less Secure Apps is enabled on the google account you’re attempting to send mail through: https://support.google.com/accounts/answer/6010255?hl=en
Also you can echo the output from $this->email->print_debugger() to get a more detailed error message.