To Send Mail From Localhost Using Codeigniter follow the steps
First:
Create a file named as "email.php" in "application/config" (to autoload the file)
<?php
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'yourmail@gmail.com'; //change this
$config['smtp_pass'] = 'yourmailpassword'; //change this
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard
?>
Second:
Create a controller file named as "Sendmail" in controller folder and paste the following code;
<?php
class Sendmail extends CI_Controller {
function index()
{
$configs = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_user' => 'yourmail@gmail.com',
'smtp_pass' => 'yourmailpassword',
'smtp_port' => '465'
);
$this->load->library("email", $configs);
$this->email->set_newline("\r\n");
$this->email->from('yourmail@gmail.com', 'Bharat Prajapat');
$this->email->to('yourmail@gmail.com');
$this->email->subject("This is Test Subject.");
$this->email->message("Body of the Message");
if($this->email->send())
{
echo "Done!";
}
else
{
echo $this->email->print_debugger();
}
}
}
?>
It's Done check you mail
First:
Create a file named as "email.php" in "application/config" (to autoload the file)
<?php
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'yourmail@gmail.com'; //change this
$config['smtp_pass'] = 'yourmailpassword'; //change this
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard
?>
Second:
Create a controller file named as "Sendmail" in controller folder and paste the following code;
<?php
class Sendmail extends CI_Controller {
function index()
{
$configs = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_user' => 'yourmail@gmail.com',
'smtp_pass' => 'yourmailpassword',
'smtp_port' => '465'
);
$this->load->library("email", $configs);
$this->email->set_newline("\r\n");
$this->email->from('yourmail@gmail.com', 'Bharat Prajapat');
$this->email->to('yourmail@gmail.com');
$this->email->subject("This is Test Subject.");
$this->email->message("Body of the Message");
if($this->email->send())
{
echo "Done!";
}
else
{
echo $this->email->print_debugger();
}
}
}
?>
It's Done check you mail