Change 'From' field of magento contact form email to the sender

前端 未结 2 552
天涯浪人
天涯浪人 2021-01-01 04:00

How would one go about changing the \'From\' field of the contact form email to that of the sender\'s? For instance, if a customer was to fill in the form with the email \'t

2条回答
  •  执念已碎
    2021-01-01 04:36

    The place where this gets sent is in app/code/core/Mage/Contacts/controllers/IndexController.php at abouts line 100. It looks like the reply-to address for the emails is already set to the email address from the post, so if you're just looking to get easier replies, I'd suggest not fooling with it.

    Another issue that you'll likely see is that sending email with a spoofed "from" address may cause your site to quickly become blacklisted from many email providers, which may affect the rest of your business.

    That said, if you still want to do this, in that file change this code a bit:

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

    Hope that helps!

    Thanks, Joe

提交回复
热议问题