sendEmail(){
// Load the email library
$this->load->library('email');
// Mail config
$to ='name@example.com';
$from = 'from@example.com';
$fromName = 'Codeigniter';
$mailSubject = 'Email Sent By Tester';
// Mail content
$mailContent = '<h2>Email Sent Successfully</h2>';
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'example@abcd.com',
'smtp_pass' => 'xxxxxxxxx',
'smtp_auth' => true,
'mailtype' => 'html',
'charset' => 'utf-8'
);
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->to($to);
$this->email->from($from, $fromName);
$this->email->subject($mailSubject);
$this->email->message($mailContent);
$this->email->set_newline("\r\n");
if($this->email->send())
{
echo "Email Sent";
}
else
{
show_error($this->email->print_debugger());
}
}
Comments
Post a Comment