There was an error while loading. Please reload this page.
1 parent b4b51a3 commit e38c34aCopy full SHA for e38c34a
config/params.php
@@ -2,4 +2,6 @@
2
3
return [
4
'adminEmail' => 'admin@example.com',
5
+ 'senderEmail' => 'noreply@example.com',
6
+ 'senderName' => 'Example.com mailer',
7
];
models/ContactForm.php
@@ -52,7 +52,8 @@ public function contact($email)
52
if ($this->validate()) {
53
Yii::$app->mailer->compose()
54
->setTo($email)
55
- ->setFrom([$this->email => $this->name])
+ ->setFrom([Yii::$app->params['senderEmail'] => Yii::$app->params['senderName']])
56
+ ->setReplyTo([$this->email => $this->name])
57
->setSubject($this->subject)
58
->setTextBody($this->body)
59
->send();
0 commit comments