MailWidget.php
905 Bytes
1
2
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
<?php
namespace common\components;
require( __DIR__.'/../../vendor/phpmailer/phpmailer/PHPMailerAutoload.php');
use yii\base\Widget;
use yii\helpers\Html;
class MailWidget extends Widget{
    public $message;
    public $email;
    public $text;
    public $subject;
    public function init(){
        parent::init();
    }
    public function run(){
        $mail = new \PHPMailer;
        $mail->IsSMTP();
        $mail->CharSet = 'UTF-8';
        $mail->Host = '192.168.10.15';
        $mail->Username = "butik@bareks.com.ua";
        $mail->SetFrom($mail->Username);
        $mail->Subject = $this->subject;
        $mail->MsgHTML($this->text);
        $address = "dockdep@gmail.com";
        $mail->AddAddress($address);
        if(!$mail->send()) {
            return 'Mailer Error: ' . $mail->ErrorInfo;
        } else {
            return 'Message has been sent';
        }
    }
}