|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
namespace app\models;
|
|
namespace app\models;
|
|
|
|
|
|
|
|
|
|
+use Yii;
|
|
|
use yii\base\Model;
|
|
use yii\base\Model;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -48,13 +49,12 @@ class ContactForm extends Model
|
|
|
public function contact($email)
|
|
public function contact($email)
|
|
|
{
|
|
{
|
|
|
if ($this->validate()) {
|
|
if ($this->validate()) {
|
|
|
- $name = '=?UTF-8?B?' . base64_encode($this->name) . '?=';
|
|
|
|
|
- $subject = '=?UTF-8?B?' . base64_encode($this->subject) . '?=';
|
|
|
|
|
- $headers = "From: $name <{$this->email}>\r\n" .
|
|
|
|
|
- "Reply-To: {$this->email}\r\n" .
|
|
|
|
|
- "MIME-Version: 1.0\r\n" .
|
|
|
|
|
- "Content-type: text/plain; charset=UTF-8";
|
|
|
|
|
- mail($email, $subject, $this->body, $headers);
|
|
|
|
|
|
|
+ Yii::$app->mail->compose()
|
|
|
|
|
+ ->setTo($email)
|
|
|
|
|
+ ->setFrom([$this->email => $this->name])
|
|
|
|
|
+ ->setSubject($this->subject)
|
|
|
|
|
+ ->setTextBody($this->body)
|
|
|
|
|
+ ->send();
|
|
|
return true;
|
|
return true;
|
|
|
} else {
|
|
} else {
|
|
|
return false;
|
|
return false;
|