Send mail From CodeIgniter Using Gmail API

here is Your Controller Function just Call This


public function alert()
{
   //$data['demo'] = $this->mreminder->mainfunction();
//$data = $this->mreminder->mainfunction();
//print_r($data);

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'nileshyadav326@gmail.com';
$config['smtp_pass'] = '******';


$this->load->library('email', $config);
$this->email->set_newline("\r\n");

$this->email->from('nileshyadav326@gmail.com', 'Nilesh yadav');
$this->email->to('nileshyadav326@gmail.com');
$this->email->subject('This is an email test');
$this->email->message('It is working. Great!');


if($this->email->send())
{
echo 'Your email was sent, successfully.';
}

else
{
show_error($this->email->print_debugger());
}

}

1 comment: