diff --git a/config/params.php b/config/params.php index 6ebf279..981c621 100644 --- a/config/params.php +++ b/config/params.php @@ -2,4 +2,6 @@ return [ 'adminEmail' => 'admin@example.com', + 'senderEmail' => 'noreply@example.com', + 'senderName' => 'Example.com mailer', ]; diff --git a/models/ContactForm.php b/models/ContactForm.php index 0b13cb0..f001d21 100644 --- a/models/ContactForm.php +++ b/models/ContactForm.php @@ -52,7 +52,8 @@ class ContactForm extends Model if ($this->validate()) { Yii::$app->mailer->compose() ->setTo($email) - ->setFrom([$this->email => $this->name]) + ->setFrom([Yii::$app->params['senderEmail'] => Yii::$app->params['senderName']]) + ->setReplyTo([$this->email => $this->name]) ->setSubject($this->subject) ->setTextBody($this->body) ->send();