From 79b81609209b3e0f1ad89692165019a7cbaa10c8 Mon Sep 17 00:00:00 2001 From: dev-chiefworks Date: Sat, 15 Apr 2023 11:31:29 -0400 Subject: [PATCH] send emsil --- JUNK/js/script.js | 2 +- app/Config/Email.php | 20 +++++++------ app/Config/Routes.php | 1 + app/Controllers/Home.php | 59 ++++++++++++++++++++++++++++++++++++++ app/Views/contact.php | 12 ++++---- public/assets/js/script.js | 2 +- 6 files changed, 81 insertions(+), 15 deletions(-) diff --git a/JUNK/js/script.js b/JUNK/js/script.js index 20c36c6..c0e17cb 100644 --- a/JUNK/js/script.js +++ b/JUNK/js/script.js @@ -326,7 +326,7 @@ $(document).ready(function($) { $.ajax({ type: "POST", - url: 'contact.php', + url: 'contact', dataType: 'json', cache: false, data: $('#contact-form').serialize(), diff --git a/app/Config/Email.php b/app/Config/Email.php index 1d0c181..b57d6e6 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -47,35 +47,39 @@ class Email extends BaseConfig * * @var string */ - public $SMTPHost; - + //public $SMTPHost; + public $SMTPHost= "ssl://smtp.google.com"; //'smtp.google.com'; /** * SMTP Username * * @var string */ - public $SMTPUser; + //public $SMTPUser; + public $SMTPUser='support@chiefsoft.com'; + /** * SMTP Password * * @var string */ - public $SMTPPass; - + //public $SMTPPass; + //public $SMTPPass; + public $SMTPPass='may12002!'; /** * SMTP Port * * @var integer */ - public $SMTPPort = 25; + //public $SMTPPort = 25; + public $SMTPPort = 465; // 993; //465;587; // /** * SMTP Timeout (in seconds) * * @var integer */ - public $SMTPTimeout = 5; + public $SMTPTimeout = 50; /** * Enable persistent SMTP connections @@ -90,7 +94,7 @@ class Email extends BaseConfig * @var string */ public $SMTPCrypto = 'tls'; - + //public $SMTPCrypto = 'ssl'; // 'tls'; /** * Enable word-wrap * diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 31f0c54..681f36b 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -37,6 +37,7 @@ $routes->get('/', 'Home::index'); $routes->get('/about', 'Home::about'); $routes->get('/services', 'Home::services'); $routes->get('/contact', 'Home::contact'); +$routes->post('/contact', 'Home::contactSend'); /* * -------------------------------------------------------------------- diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 1090d6c..d80c82f 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -29,4 +29,63 @@ class Home extends BaseController $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; + } } diff --git a/app/Views/contact.php b/app/Views/contact.php index c711f63..f5dfa4a 100644 --- a/app/Views/contact.php +++ b/app/Views/contact.php @@ -24,8 +24,8 @@ - - + +
@@ -57,8 +57,9 @@

Send us a message

-
- + + +
@@ -66,7 +67,7 @@
- +
@@ -104,4 +105,5 @@ endSection() ?> + \ No newline at end of file diff --git a/public/assets/js/script.js b/public/assets/js/script.js index 20c36c6..c0e17cb 100644 --- a/public/assets/js/script.js +++ b/public/assets/js/script.js @@ -326,7 +326,7 @@ $(document).ready(function($) { $.ajax({ type: "POST", - url: 'contact.php', + url: 'contact', dataType: 'json', cache: false, data: $('#contact-form').serialize(),