Change the From field of the magento contact form message to the sender

How could I change the "From" field of the contact form to the sender address? For example, if a client needs to fill out a form with the email address " test@test.com ", how can I make the created email with " test@test.com "?

I looked at the "email message sender" field in the system administration panels, but this allows only a few pre-configured emails to be used.

Thank you very much

+4
source share
2 answers

The place where it goes is in app/code/core/Mage/Contacts/controllers/IndexController.php at line 100 in line. It looks like the reply address for the email messages is already set to the email address from the message, so if you just want easier answers, I would suggest not spoofing it.

Another problem you'll probably see is that sending email with a fake "from" address can cause your site to be quickly blacklisted by many email providers, which could affect the rest part of your business.

However, if you still want to do this, change this code slightly in this file:

  $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 this helps!

Thanks Joe

+7
source

The Magento contact form - receiving email from me is a newer duplicate of this question, and Joe's answer gave me the right way. In response to a duplicate question, I wrote a special module for redefining app/code/core/Mage/Contacts/controllers/IndexController.php and eventually changed the above line to array('name'=>$post['name'], 'email'=>$post['email']), , to fix.

IMHO, when I make urgent small corrections in the kernel that should remain until it is correctly overloaded, I will definitely end each line with comments with my initials twice //CKCK hack to fix ___ , and then you can grep for this and see all your mods through the ssh shell: app/code/core$ grep -rn "CKCK" *

I also use github for version control, which also helps.

+1
source

All Articles