Question

My Website is a shopping website(Currently in Dev)...

Im using a CMS which sends emails to customers after they have made a purchase giving details about their order.

Can i use javascript within the email template to check for a condition.Basically this email will be going out to 'N' number of users and i have a 'X' number of user who should get a slightly modified email based on a condition.

HERE IS THE TEMPLATE.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Untitled Page</title>
    </head>
    <body>
        BLAH BLAH BLAH
        <span style="font-family: arial;">Thank you. Your order is confirmed. Please print a copy for your records.</span>        
       BLAH BLAH BLAH
    </body>
</html>

I understand that most email clients do not support Javascript, So is there any way within the email itself that i can change the contents of the mail based on conditions i choose.

Was it helpful?

Solution

I got this to work... The solution was to have the condition server side using a xsl template

<xsl:if test="expression">
  ...some output if the expression is true...
</xsl:if>

OTHER TIPS

As suggested, you need to make your changes first as the email has to go out statically (as is).

This is often referred to as "dynamic content" in the email marketing world, and is the most effective way to send different versions of the email. Most ESP's have dynamic content or the more simple "merge tags" to do this.

This is a technique used for mass emailing one email to many (usually marketing/promos etc), while you are intending on sending an email based on individual user actions. I'd suggest you look into a "transactional email", a service like Mandrill, Sendgrid or Mailjet would be ideal to power this for you. Each has a solid API and is cost effective.

There is only one way to switch content after sending an email - updating an image. If you are linking to an image hosted on your server, you can update it there and it will display in its current state is when the email is opened.

Can i do this in the email?

No, and you should do that stuff server-side, that's pretty much the standard.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top