Created
February 22, 2017 18:15
-
-
Save josephmcdermott/6e1989b80cf7fc9d24d562024e14f3fa to your computer and use it in GitHub Desktop.
Magento2 add customer name to Contact Form Reply-To header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# etc/di.xml | |
<?xml version="1.0"?> | |
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | |
<preference for="Magento\Contact\Controller\Index\Post" type="path\to\your\Post" /> | |
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# path/to/your/Post.php | |
<?php | |
class Post extends \Magento\Contact\Controller\Index | |
{ | |
public function execute() | |
{ | |
... | |
->setFrom($this->scopeConfig->getValue(self::XML_PATH_EMAIL_SENDER, $storeScope)) | |
->addTo($this->scopeConfig->getValue(self::XML_PATH_EMAIL_RECIPIENT, $storeScope)) | |
// added second parameter here for the name | |
->setReplyTo($post['email'], $post['name']) | |
->getTransport(); | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment