Magento – How to change reply-to email adress of contact form when using transactional email template

contact-usemailemail-templatestransactional

I am using a custom template for the contact form because I need a unique subject line for incoming contact form. I got that working by using a custom transactional email template. But now I came across a new problem: the reply-to email is set to an email address of our store instead of the person who filled in the form.

How can I use the customer's email address as the reply-to address?

Best Answer

The code which sends the contacts email is:

$post = $this->getRequest()->getPost();
// ... more code ...
$mailTemplate->setDesignConfig(array('area' => 'frontend'))
    ->setReplyTo($post['email'])
    ->sendTransactional(
        Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
        Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
        Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
        null,
        array('data' => $postObject)
    );

You can see, it uses the value email which was posted from the contacts form, which actually is exactly what you want. Some modification you or an extension you installed must have changed the default behavior.