garyhoffmann Posted June 17, 2022 Share Posted June 17, 2022 (edited) This has been an issue from the start, but we have not had a ton of sales. However, sales are picking up and now we want to address it. We are using PS 1.7.5.1. We have the Mail Alerts downloaded. We have Version 2.2.1 which seems like it is the latest as it does not show up on our updates tab. When the email comes to us, it has all of the template tags in it still. For example, it says "A new order was placed on {shop_name} by the following customer: {firstname} {lastname} ({email})" rather than the replacements for those variables. This is true for the entire template. The module has the code to fill all of those template variables in ps_emailalerts.php in the function hookActionValidateOrder. What do you suppose might be causing this to not work correctly? We'd love to get the emails working as expected, but don't know where to start troubleshooting this. We have looked at the vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plubins folder and the DecoratorPlugin.php seems to be OK (but I have not studied it completely). We have looked at the Mail class (MailCore) and it seems OK. I'm just looking for a pointer in the right direction to see if I can figure out what might be going on. Thanks in advance, Gary. Edited June 17, 2022 by garyhoffmann (see edit history) Link to comment Share on other sites More sharing options...
garyhoffmann Posted June 19, 2022 Author Share Posted June 19, 2022 I figured out what was going on. The store admin had a mixed case address for the email to portion of the EmailAlerts. Once I put this in as all lowercase, it worked as expected. However, that got me to thinking - people can obviously enter a mixed case email address. Therefore, I continued searching now that I knew what the problem might be. Inside of classes/Mail.php, it had the following code: /* Construct multiple recipients list if needed */ $message = \Swift_Message::newInstance(); if (is_array($to) && isset($to)) { foreach ($to as $key => $addr) { $addr = trim($addr); if (!Validate::isEmail($addr)) { self::dieOrLog($die, 'Error: invalid e-mail address'); return false; } if (is_array($toName) && isset($toName[$key])) { $addrName = $toName[$key]; } else { $addrName = $toName; } $addrName = ($addrName == null || $addrName == $addr || !Validate::isGenericName($addrName)) ? '' : self::mimeEncode($addrName); $message->addTo(self::toPunycode($addr), $addrName); } $toPlugin = $to[0]; } else { /* Simple recipient, one address */ $toPlugin = $to; $toName = (($toName == null || $toName == $to) ? '' : self::mimeEncode($toName)); $message->addTo(self::toPunycode($to), $toName); } I needed to change the $toPlugin to use the toPunyCode equivalent. So, I now have: /* Construct multiple recipients list if needed */ $message = \Swift_Message::newInstance(); if (is_array($to) && isset($to)) { foreach ($to as $key => $addr) { $addr = trim($addr); if (!Validate::isEmail($addr)) { self::dieOrLog($die, 'Error: invalid e-mail address'); return false; } if (is_array($toName) && isset($toName[$key])) { $addrName = $toName[$key]; } else { $addrName = $toName; } $addrName = ($addrName == null || $addrName == $addr || !Validate::isGenericName($addrName)) ? '' : self::mimeEncode($addrName); $message->addTo(self::toPunycode($addr), $addrName); } $toPlugin = self::toPunycode($to[0]); //TA Added was $to[0]; } else { /* Simple recipient, one address */ $toPlugin = self::toPunycode($to); // TA Added was $to; $toName = (($toName == null || $toName == $to) ? '' : self::mimeEncode($toName)); $message->addTo(self::toPunycode($to), $toName); } That seems to fix it. The problem is that the plugin was receiving the address with mixed case, but the to address had been converted to all lowercase by the toPunycode call in the $message->addTo call, so the DecoratorPlugin was never finding the correct replacements. Since people can enter a mixed case address, I figured this was the only safe way of handling it across the board. I tested by resetting the admin email to mixed case, plus I entered a mixed case address as the customer. Both received the correctly formatted emails, so I believe we can put this one to rest. If anyone from Prestashop looks at these messages, PLEASE make sure that Mail.php is setup correctly for the future versions. Thanks. 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