Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 '[email protected]', how can I make the generated email be from '[email protected]'?

I've looked at the 'email sender' field in the system admin panels, but this only allows for a range of preset store emails.

Many thanks

like image 936
Geoff Avatar asked Feb 24 '23 01:02

Geoff


1 Answers

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

like image 187
Joe Mastey Avatar answered Feb 26 '23 15:02

Joe Mastey