From 7af1c1f46de684f5def852d2da21910b61323981 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 6 Jan 2017 13:07:39 +0200 Subject: [PATCH] -Mail and Map --- common/widgets/Mailer.php | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------- frontend/views/site/index.php | 6 +++--- 2 files changed, 61 insertions(+), 47 deletions(-) diff --git a/common/widgets/Mailer.php b/common/widgets/Mailer.php index 098d002..af91bb0 100755 --- a/common/widgets/Mailer.php +++ b/common/widgets/Mailer.php @@ -1,49 +1,63 @@ IsSMTP(); - $mail->CharSet = 'UTF-8'; - $mail->SMTPDebug = 2; - $mail->SMTPAuth = true; - $mail->SMTPSecure = 'tls'; - $mail->Host = "smtp.gmail.com"; - $mail->Port = 587; // 465 or 587 - $mail->Username = "nissanleaf17@gmail.com"; // Google email account - $mail->Password = "parol123"; // Password to this account - $mail->SetFrom("leaf@electrocars.ua"); - $mail->isHTML(true); - $mail->Subject = $this->subject; - $mail->Body = $this->render($this->type, ['params' => $this->params]); - $mail->AddAddress('kennen.md@gmail.com'); - $mail->AddAddress('pmartweb1@gmail.com'); - if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; - } else { - echo "Message has been sent"; + namespace common\widgets; + + use yii\base\Widget; + + class Mailer extends Widget + { + public $message; + public $email; + public $text; + public $subject; + public $type; + public $params; + + public function init() + { + + parent::init(); + + } + + public function run() + { + $headers = "MIME-Version: 1.0\r\n"; + $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; + if (mail( + 'leaf@electrocars.ua', + $this->subject, + $this->render($this->type, [ 'params' => $this->params ]), + $headers + )) { + echo 'ok'; + } else { + echo 'fail'; + } + + // $mail = new \PHPMailer(); + // + // $mail->IsSMTP(); + // $mail->CharSet = 'UTF-8'; + // $mail->SMTPDebug = 2; + // $mail->SMTPAuth = true; + // $mail->SMTPSecure = 'tls'; + // $mail->Host = "smtp.gmail.com"; + // $mail->Port = 587; // 465 or 587 + // $mail->Username = "kennen.md@gmail.com"; // Google email account + // $mail->Password = "nobeernoparty"; // Password to this account + // $mail->SetFrom("leaf@electrocars.ua"); + // $mail->isHTML(true); + // $mail->Subject = $this->subject; + // $mail->Body = $this->render($this->type, ['params' => $this->params]); + // $mail->AddAddress('kennen.md@gmail.com'); + //// $mail->AddAddress('pmartweb1@gmail.com'); + // if(!$mail->Send()) { + // echo "Mailer Error: " . $mail->ErrorInfo; + // } else { + // echo "Message has been sent"; + // } } + } -} - diff --git a/frontend/views/site/index.php b/frontend/views/site/index.php index d451062..8f6a400 100755 --- a/frontend/views/site/index.php +++ b/frontend/views/site/index.php @@ -496,12 +496,12 @@