Skip to content

Commit e38c34a

Browse files
committed
Adjusted email headers in contact form
See yiisoft/yii2-app-advanced#426
1 parent b4b51a3 commit e38c34a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

config/params.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
return [
44
'adminEmail' => 'admin@example.com',
5+
'senderEmail' => 'noreply@example.com',
6+
'senderName' => 'Example.com mailer',
57
];

models/ContactForm.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public function contact($email)
5252
if ($this->validate()) {
5353
Yii::$app->mailer->compose()
5454
->setTo($email)
55-
->setFrom([$this->email => $this->name])
55+
->setFrom([Yii::$app->params['senderEmail'] => Yii::$app->params['senderName']])
56+
->setReplyTo([$this->email => $this->name])
5657
->setSubject($this->subject)
5758
->setTextBody($this->body)
5859
->send();

0 commit comments

Comments
 (0)