Hello Readers, In this blog I am providing information about How to Send Email through CodeIgniter Programming.
Sending Email in CodeIgniter is very Simple. Configuration of Email can be done in one of the Controller file of our Application as shown below :
//Load the pre defined helper Library 'Email'
$this->load->library('email');
$this->email->from('Test@example.com', 'Our Name');
$this->email->to('Someone@example.com');
$this->email->cc('Another@example.com');
$this->email->bcc('test@example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email sending ');
$this->email->send();
echo $this->email->print_debugger(); //Show the Result
For Example :
function Mail()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx@gmail.com',
'smtp_pass' => 'xxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = 'Sending mail through codeigniter from localhost';
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('xxx@gmail.com');
$this->email->to('xxx@gmail.com');
$this->email->subject('Email from CodeIgniter');
$this->email->message($message);
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
0 Comment(s)