diff --git a/app/Config/Email.php b/app/Config/Email.php index 1749663..425acd5 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -48,14 +48,14 @@ class Email extends BaseConfig * @var string */ //public $SMTPHost; - public $SMTPHost= "smtp.google.com"; //'smtp.google.com'; + public $SMTPHost="smtp.sendgrid.net"; // "smtp.google.com"; //'smtp.google.com'; /** * SMTP Username * * @var string */ //public $SMTPUser; - public $SMTPUser='support@chiefsoft.com'; + public $SMTPUser= 'apikey'; //support@chiefsoft.com'; /** @@ -65,7 +65,7 @@ class Email extends BaseConfig */ //public $SMTPPass; //public $SMTPPass; - public $SMTPPass='nocemrnhjukvsekc'; //'may12002!'; + public $SMTPPass='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'; // 'nocemrnhjukvsekc'; //'may12002!'; /** * SMTP Port * diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index d80c82f..91134fb 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -44,7 +44,8 @@ class Home extends BaseController 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 ); + // $this->notifyMessage( $message_to_send ); + $this->notifyMessage2( $message_to_send ); } return $this->contact(); @@ -58,15 +59,19 @@ class Home extends BaseController $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['protocol'] = 'smtp'; $config['mailPath'] = '/usr/sbin/sendmail'; $config['charset'] = 'iso-8859-1'; $config['wordWrap'] = true; + $config['SMTPCrypto'] ='imapSSL'; + $config['SMTPPort'] = 993; // 587; // 465 + $config['SMTPTimeout'] = 10; + $config['SMTPHost'] = 'imap.gmail.com'; - //$email->initialize($config); + $email->initialize($config); $email->setTo($to); - $email->setFrom('support@chiefsoft.com', 'KevKem Support');//set From + $email->setFrom('ameye@chiefsoft.com', 'KevKem Support');//set From $email->setSubject($subject); $email->setMessage($message); if($email->send()) @@ -88,4 +93,65 @@ class Home extends BaseController } return $data; } + + +private function notifyMessage2( $message_to_send ) +{ + /* + * + mailsend: +{ + from = "support@wrenchboard.com"; + server = "smtp.gmail.com"; + domain = "wrenchboard.com"; + user = "support@wrenchboard.com"; + pass = "may12002!"; + name = "WrenchBoard Demo Support"; +}; + + */ + + $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'] = 'smtp'; + $config['mailPath'] = '/usr/sbin/sendmail'; + $config['charset'] = 'iso-8859-1'; + $config['wordWrap'] = true; + $config['SMTPCrypto'] ='SSL'; + $config['SMTPPort'] = 465; // 993 465; // 587; // 465 + $config['SMTPTimeout'] = 10; + $config['SMTPUser'] = 'apikey'; + $config['SMTPHost'] = 'smtp.sendgrid.net'; + $config['SMTPPass'] = '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'; + + $email->initialize($config); + + $email->setTo($to); + $email->setFrom('ameye@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 sent '.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 on 2" ); + //log_message('critical',$data ); + + //print_r($data); + } + return $data; + + } }