Jump to content

Email placeholders not replaced with values


Jerir90

Recommended Posts

I'm using Prestashop 1.7.6.0 on a new site that I'm developing and I have a problem that on all emails, none of the placeholders are replaced with their values.

So for example the Password Query email arrives looking as follows.

 

Hi {firstname} {lastname},

Confirmation of password request on {shop_name}

You have requested to reset your {shop_name} login details.

Please note that this will change your current password.

In order to confirm this action, click on the following link: {url}

 

There are no errors shown when an email is sent, and nothing is added to the php error log.

I'm using a custom theme, but I have the same problem if I revert back to the Classic theme.

I started the development using Prestashop 1.7.4 but have recently upgraded to 1.7.6.0. I didn't test sending emails on the earlier versions so can't say if they worked before the upgrade.

There have been no changes made to the Mail.php class and there is no override of that class either.

Anyone got any ideas?

Thanks

 

 

Link to comment
Share on other sites

Some extra information.

I've now made a clean install of PS 1.7.6.1 with no custom theme or any additional modules, and that has the same problem.

I'm installing it locally using Wamp as my web server, but the problem persists when I upload the site to my web hosting.

I also have another website that uses PS 1.5.6 installed locally, and that has no such problems.

Is there any additional setup required for emails on PS 1.7?

Does anyone have any suggestions?

Link to comment
Share on other sites

Finally figured out what's happening. 

In Mail.php, the Replacements array is specified with a key of the 'To' address.  However, the 'To' address on the email is modified by the toPunycode() function.  If this changes the case of the characters in the 'To' address, then it will no longer find a match in the Replacements array and so will not update the placeholders.

I've amended Mail.php so that when $toPlugin is set, it is set to self::toPunyCode()

Note sure why nobody else seems to have this issue.

Link to comment
Share on other sites

  • 2 months later...

Hi Again

I solved it

The trouble is when user set email in UPPERCASE like [email protected] ,

I create a override/classes/Mail.php

with code

 

class Mail extends MailCore {

public static function send(
        $idLang,
        $template,
        $subject,
        $templateVars,
        $to,
        $toName = null,
        $from = null,
        $fromName = null,
        $fileAttachment = null,
        $mode_smtp = null,
        $templatePath = _PS_MAIL_DIR_,
        $die = false,
        $idShop = null,
        $bcc = null,
        $replyTo = null,
        $replyToName = null
    )
    {

       $to = strtolower($to);

    return parent::Send($idLang, $template, $subject, $templateVars, $to, $toName, $from, $fromName, $fileAttachment, $mode_smtp, $templatePath, $die, $idShop, $bcc, $replyTo);
    }

}

and now it works ok

 

thanks a lot

Link to comment
Share on other sites

  • 2 months later...
On 11/28/2019 at 7:40 PM, jcata said:

Hi Again

I solved it

The trouble is when user set email in UPPERCASE like [email protected] ,

I create a override/classes/Mail.php

with code

 

class Mail extends MailCore {

public static function send(
        $idLang,
        $template,
        $subject,
        $templateVars,
        $to,
        $toName = null,
        $from = null,
        $fromName = null,
        $fileAttachment = null,
        $mode_smtp = null,
        $templatePath = _PS_MAIL_DIR_,
        $die = false,
        $idShop = null,
        $bcc = null,
        $replyTo = null,
        $replyToName = null
    )
    {

       $to = strtolower($to);

    return parent::Send($idLang, $template, $subject, $templateVars, $to, $toName, $from, $fromName, $fileAttachment, $mode_smtp, $templatePath, $die, $idShop, $bcc, $replyTo);
    }

}

and now it works ok

 

thanks a lot

Hello, 

I'm experiencing the same issue : customers with uppercase chars in their email address do not get a proper confirmation mail.
I tried creating a new class in the override/classes folder like you did but the issue is still here...
Any idea how to fix this ? 

Thanks !

Link to comment
Share on other sites

13 minutes ago, jcata said:

Hi ,

 

the trouble editing Classes/Mail.php is if you update prestashop these change can override ..

then the best solutions is create a override/classes/Mail.php overriding default behavior..

 

greetings

Yes, that's what i was thinking.
Thing is, as I mentioned above, I tried to override with override/classes/Mail.php .
I copied/pasted what you did but for some reason, it didn't work. If you have any idea why, I'm open to suggestions as i'd rather not edit the Classes/Mail.php ahah

Thanks 

Link to comment
Share on other sites

On 2/28/2020 at 5:18 PM, Jerir90 said:

After creating a new override, you need to delete the class_index.php file (var\cache\prod) so that Prestashop will re-create it with details of the new file.  Have you done that?

Thanks for this, as you guessed, I didn't delete this file the 1st time I tried.
I just did and it still doesn't work.
 

I looked into the file after Prestashop re-created it and I found this

 array (
    'path' => 'override/classes/Mail.php',
    'type' => 'class',
    'override' => false,
  ),

Should I change 'override' to true ?

Thing is, my solution (add strtolover() in the main Mail.php) works on my TEST website but not of my PROD website (TEST being a replica of PROD that customers can't reach) which i can't explain either...
Do you guys have any idea ? 

Thanks !

Link to comment
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...