Adjusted email headers in contact form

See https://github.com/yiisoft/yii2-app-advanced/issues/426
This commit is contained in:
Alexander Makarov 2019-04-23 15:11:10 +03:00
parent b4b51a3fb9
commit e38c34a935
No known key found for this signature in database
GPG Key ID: 3617B79C6A325E4A
2 changed files with 4 additions and 1 deletions

View File

@ -2,4 +2,6 @@
return [ return [
'adminEmail' => 'admin@example.com', 'adminEmail' => 'admin@example.com',
'senderEmail' => 'noreply@example.com',
'senderName' => 'Example.com mailer',
]; ];

View File

@ -52,7 +52,8 @@ class ContactForm extends Model
if ($this->validate()) { if ($this->validate()) {
Yii::$app->mailer->compose() Yii::$app->mailer->compose()
->setTo($email) ->setTo($email)
->setFrom([$this->email => $this->name]) ->setFrom([Yii::$app->params['senderEmail'] => Yii::$app->params['senderName']])
->setReplyTo([$this->email => $this->name])
->setSubject($this->subject) ->setSubject($this->subject)
->setTextBody($this->body) ->setTextBody($this->body)
->send(); ->send();