Blame view

common/widgets/Mailer.php 2.07 KB
eb56e5f2   Administrator   first commit
1
  <?php

eb56e5f2   Administrator   first commit
2
      

7af1c1f4   Alexey Boroda   -Mail and Map
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
      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";

              //        }

eb56e5f2   Administrator   first commit
60
          }

7af1c1f4   Alexey Boroda   -Mail and Map
61
          

eb56e5f2   Administrator   first commit
62
63
      }