Files
KevKemChiro/app/Controllers/Home.php
T
dev-chiefworks 79b8160920 send emsil
2023-04-15 11:31:29 -04:00

92 lines
2.6 KiB
PHP

<?php
namespace App\Controllers;
class Home extends BaseController
{
public function index()
{
$data =[];
$data['page'] = 'home';
return view('home',$data);
}
public function services()
{
$data =[];
$data['page'] = 'services';
return view('services',$data);
}
public function about()
{
$data =[];
$data['page'] = 'about';
return view('about',$data);
}
public function contact()
{
$data =[];
$data['message'] = '';
$data['page'] = 'contact';
return view('contact',$data);
}
public function contactSend(){
if ($_POST){
log_message('critical', "Post Message -Entered" );
$name = $_POST['name'];
$email= $_POST['email'];
$message= $_POST['comment'];
log_message('critical', "Post Message -Entered".$name );
log_message('critical', "Post Message -Entered".$email );
log_message('critical', "Post Message -Entered".$message );
$message_to_send = "This is the message Ya YA ";
$this->notifyMessage( $message_to_send );
}
return $this->contact();
}
private function notifyMessage( $message_to_send )
{
$data =[];
$to = 'ameye@chiefsoft.com';//Type here the mail address where you want to send
$subject = 'KevKem Site Message';//Write here Subject of Email
$message= $message_to_send; //'Conngrats ! You did it. -- '.rand(1000,9999);//Write the message you want to send
$email = \Config\Services::email();
$config['protocol'] = 'sendmail';
$config['mailPath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordWrap'] = true;
//$email->initialize($config);
$email->setTo($to);
$email->setFrom('support@chiefsoft.com', 'KevKem Support');//set From
$email->setSubject($subject);
$email->setMessage($message);
if($email->send())
{
//echo 'Email has been Sent.';
log_message('critical', "Email has been Sent" );
$data['msg'] ='All good '.rand(100,9999);
}
else{
// echo 'Something went wrong !';
$data['error'] = $email->printDebugger(['headers']);
log_message('critical', "Something went ERROR --- . ". serialize($data['error']) );
;
log_message('critical', "Something went wrong" );
//log_message('critical',$data );
//print_r($data);
}
return $data;
}
}