manu1987 Posted February 2, 2015 Share Posted February 2, 2015 Hi there, I changed my prestashop e-mail configuration to plain text e-mails. Now, when a customer wants to send a message through the contact form, I receive the line breaks as text, e.g. "This is a line break</br>And this is a new line." I would like to receive it that way: "This is a line break And this is a new line." Is there a solution to it? Someone already asked exactly this about two years ago, topic "contact-form.tpl received messages with <br /> tags NEED HELP PS" but that guy never received an answer. Link to comment Share on other sites More sharing options...
manu1987 Posted February 5, 2015 Author Share Posted February 5, 2015 Anyone? Link to comment Share on other sites More sharing options...
solidsteak Posted February 3, 2017 Share Posted February 3, 2017 (edited) I modified controllers/front/ContactController.php with an override. This line in particular: '{message}' => Tools::nl2br(stripslashes($message)), I added a simple php search and replace function around the message. Just replacing all instances of <br> with "\r\n". And since there may be different ways to write <br> <br/> <br />, I added an array to search from before this modification. $breaks = array("<br />","<br>","<br/>"); if (!count($this->errors)) { $var_list = array( '{order_name}' => '-', '{attached_file}' => '-', '{message}' => str_ireplace($breaks,"\r\n",Tools::nl2br(stripslashes($message))), ... } } Edited February 3, 2017 by solidsteak (see edit history) Link to comment Share on other sites More sharing options...
mausbaus Posted December 10, 2019 Share Posted December 10, 2019 Anyone has an update for PS 1.7.6.1? I am getting the same html tags even if PS is set to send text messages only and adding the above code in contact controller breaks the contact page. Link to comment Share on other sites More sharing options...
solidsteak Posted December 10, 2019 Share Posted December 10, 2019 I don't use 1.7, but quickly looking at my old files I downloaded it looks like the contact form is now a module. /modules/contactform/contactform.php It appears the code block in question starts at line 581. If I'm not mistaken, the same approach should work. I would use an override to maintain upgradeability. Link to comment Share on other sites More sharing options...
mausbaus Posted December 10, 2019 Share Posted December 10, 2019 It works! Thank you for your awesomeness! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now