Skip to content

Instantly share code, notes, and snippets.

@josephmcdermott
Created February 22, 2017 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephmcdermott/6e1989b80cf7fc9d24d562024e14f3fa to your computer and use it in GitHub Desktop.
Save josephmcdermott/6e1989b80cf7fc9d24d562024e14f3fa to your computer and use it in GitHub Desktop.
Magento2 add customer name to Contact Form Reply-To header
# 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>
# 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