nioc22 Posted April 30, 2014 Share Posted April 30, 2014 Hello community! I hope you are all well! I need your help for a little problem that I can't get through! In the contact form you can choose between Webmaster or Customer Service (which is differents e-mails) before an email is sent. I set an email for Customer Service, but we are 2 (sometime 3) peoples to manage this service and to answer to the customer. Is it possible to have 2 or more email set in Customer Service? I tried to separate mail by coma (,) but I got ''invalid mail'' when I did it. And it will be great if all the customer service team will received the notification from the contact form. Otherwise we always need to check if we received some mail from a customer.. Thank you in advance for your help. Nico Link to comment Share on other sites More sharing options...
PascalVG Posted April 30, 2014 Share Posted April 30, 2014 Hi Nico, Try this: Edit or override the file /classes/Validate.php (make backup, just in case!!!) (Sample code of PS 1.6.0.5) and edit the function: (add red code) public static function isEmail($email) { $emails = explode(",", $email); //!!!Pas, make more recipients in one string possible $return = true; foreach ($emails as $tmpemail) $return= ($return && !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z\p{L}0-9]+$/ui'), $tmpemail)); return $return; // return !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z\p{L}0-9]+$/ui'), $email); } and save. This code allows for a comma in the recipients Email address input field (Email of Webmaster, customer service etc) So you can now add [email protected],[email protected] Then, override or edit file /classes/Mail.php (again, make backup!) (add red code) and edit function: public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null) ... if (!Validate::isMailSubject($subject)) { Tools::dieOrLog(Tools::displayError('Error: invalid e-mail subject'), $die); return false; } /* Construct multiple recipients list if needed */ if (strpos($to, ',') !==false) // Allow multiple recipients in one string... $to = explode(',', $to); $to_list = new Swift_RecipientList(); if (is_array($to) && isset($to)) { ... and save. This will split/transform the recipients string $to in a recipients array $to, which will then be given to the rest of the mail function as usual. I hope that does the trick. pascal. 4 Link to comment Share on other sites More sharing options...
PascalVG Posted April 30, 2014 Share Posted April 30, 2014 (N.B. Another option is to do it outside Prestashop: add a forward rule to your Email box. Most Email providers can forward new Emails to other email addresses on receipt, depending on the sender field, recipient field, subject text etc.). So then just forward a copy to the other team members... My 2 cents, pascal Link to comment Share on other sites More sharing options...
nioc22 Posted May 6, 2014 Author Share Posted May 6, 2014 Thanks a lot PascalVG. Your answer was super fast!! I just came back from a long week end but I will test it for sure tomorow! I will write a update after I test it!! Thanks again! Link to comment Share on other sites More sharing options...
nioc22 Posted May 8, 2014 Author Share Posted May 8, 2014 Hello PascalVG So I tried your first solution today and it work like a charm on my shop. Now I can set multiple email for the customer service. It's perfect!! For info my shop is on 1.5.4.1 version. Thanks again for your super fast and well explain help!! You'r the best! Nico Link to comment Share on other sites More sharing options...
PascalVG Posted May 8, 2014 Share Posted May 8, 2014 Glad it works. Thanks for the feedback. I'll mark the topic solved. Happy selling, pascal. 1 Link to comment Share on other sites More sharing options...
meclarn Posted January 25, 2016 Share Posted January 25, 2016 Hello Pascal I tried this on a prestashop 1.6.1.3 by editing the classes/Validate.php and the classes/Mail.php but it still giving me an error when i add more than one email separated by comma any suggestions ? Best regards, Majd Link to comment Share on other sites More sharing options...
raunhar Posted September 27, 2016 Share Posted September 27, 2016 (edited) After making the changes as shown above, I was able to add one more mail id. But, when the form is submitted, it shows error (No details of error, screen shot attached). But when I press the Send button again, the form gets submitted. How to correct it. Edited September 27, 2016 by raunhar (see edit history) 2 Link to comment Share on other sites More sharing options...
Impe-M Posted March 7, 2017 Share Posted March 7, 2017 Hi, i've the same error in Presashop 1.6.1.9. Link to comment Share on other sites More sharing options...
Jluis Posted April 6, 2018 Share Posted April 6, 2018 bonsoir , le sujet est important , j'ai suivi le code fourni , une erreur s'est produite lors de l'envoi de l'email comme illustre la figure suivante Link to comment Share on other sites More sharing options...
ruisonika Posted October 22, 2021 Share Posted October 22, 2021 On 4/30/2014 at 9:13 PM, PascalVG said: Hi Nico, Try this: Edit or override the file /classes/Validate.php (make backup, just in case!!!) (Sample code of PS 1.6.0.5) and edit the function: (add red code) public static function isEmail($email) { $emails = explode(",", $email); //!!!Pas, make more recipients in one string possible $return = true; foreach ($emails as $tmpemail) $return= ($return && !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z\p{L}0-9]+$/ui'), $tmpemail)); return $return; // return !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z\p{L}0-9]+$/ui'), $email); } and save. This code allows for a comma in the recipients Email address input field (Email of Webmaster, customer service etc) So you can now add [email protected],[email protected] Then, override or edit file /classes/Mail.php (again, make backup!) (add red code) and edit function: public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null) ... if (!Validate::isMailSubject($subject)) { Tools::dieOrLog(Tools::displayError('Error: invalid e-mail subject'), $die); return false; } /* Construct multiple recipients list if needed */ if (strpos($to, ',') !==false) // Allow multiple recipients in one string... $to = explode(',', $to); $to_list = new Swift_RecipientList(); if (is_array($to) && isset($to)) { ... and save. This will split/transform the recipients string $to in a recipients array $to, which will then be given to the rest of the mail function as usual. I hope that does the trick. pascal. Hi Pascal, I've tried your solution in presta 1.6.1.24 but doesn't work... Do you know other way to have two emails in PS_SHOP_MAIL? If you could help see my post here. Thanks for all the help. 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