Search

The expression lets you control when each condition should be used, this is useful for more complicated forms.

The Page should be the page that generates the email (not the form that creates the entry).

And the Params are optional, although you can use them to say pass the newly created entry to the Page: ({entry/@id})

Ok, so I can pass something like this:

{entry/post-code}

Also to re-iterate, I would have to remove the event from the contact page, so that it doesn't run and send an email before I have had a chance to generate it via the special page.

Yeah, you could do that. But really, the ideal thing to do would be to pass the entry ID to the page, and attach a datasoruce to that page which fetches the desired entry.

I'm not quite sure what you mean by that last one. All the extension does with the 'generator page' is make a HTTP request to it, grab the output, then send it via an email.

S you can develop your email template in your browser just like another Symphony page.

So then how is it sent?

It's sent when the entry is created successful, as long as you have the filter attached to the event that creates the entry.

@rowanji: Started playing around with this today. So far I'm really impressed. The distinction between the sort of 'settings' and the condition is a little confusing, but the functionality is great.

The only bug I've come across is that I can't seem to remove a conditional from a template once it's been saved. I had to delete the entire template and recreate it.

I'm working with this in Sym. 2.0. My generator page is being emailed, but after that, the form/event page is being reloaded as text (non-rendered). Any idea what would cause this?

EDIT: Upgrade to 2.0.1 fixed it.

What would be the best way to disable people to manually visit the generator page and see the last e-mail generated?

I have set up the generator page (including usage of entry-id) but it is not being e-mailed. I can call it succesfully through my browser, so would this mean that there is something wrong with the HTTP request being made?

I encountered an issue with this extension 1.005 + 2.0.2 (not sure if it exists in previous versions).

My email was rendering as plain text. The cause was that the General::sendemail() function adds a 'Content-Type: text/plain' header, which this ext. tries to override by later adding a 'Content-Type: text/html' header (to correctly display the generator page output). Thunderbird apparently uses the first header, I imagine this may vary client to client.

A hack to fix this problem is to edit /symphony/lib/toolkit/class.general.php, around line #359, comment out : 'Content-Type: text/plain; charset="UTF-8"',

This will simply suppress any content-type header from being placed in symphony system emails. I don't know what issues this will cause to other emails that Symphony produces (including possibly password resets).

Any php gurus out there, this ext is a great start, but I think we could use a decent overhaul of email in Symphony, namely using configurable smtp, since many web servers mail() outputs are not trusted email senders.

I fixed some issues, it is now possible to remove conditions. See http://github.com/carsten/emailtemplatefilter/tree/master before Rowan pulls my fork...

Rowan, this extension is quite superb. This is the first time I've used it and although it took some time to figure out what's going on, I'm dead chuffed with the concept.

The above wasn't really enough for me to figure out to how to use it. I eventually worked things out by var_dump-ing my way through. Here's a quick step-by-step for creating a simple contact form:

  1. Create a section to collect your contact information details (name, email, message etc.)

  2. Create an Event in the normal way and write your HTML to post data into this section.

  3. Install the Email Template extension and create a new Template

"Conditions" allow you to change the to/from and subject/body of the email depending on options from your data collected. I didn't fully understand what each field inside a Condition meant, so here's my explanation:

Subject — the subject line for the email Sender Name — the text name of the sender Senders — email address from which it is sent Recipients — email addresses to which the email is sent

The powerful thing here is that these can be dynamic, driven by Xpath queries. Originally I tried using full Xpath queries to my original page XML, but the XML you can query will be in the form:

<data>
    <param>
        <today>2009-03-21</today>
        <current-time>11:03</current-time>
        <this-year>2009</this-year>
        <this-month>03</this-month>
        <this-day>21</this-day>
        <timezone>+00:00</timezone>
        <website-name>Symphony Content Management System</website-name>
        <!-- shortened -->
    </param>
    <entry id="171154">
        <name handle="nick">Nick</name>
        <email handle="nickdunn-airlockcom">nick.dunn@airlock.com</email>
        <!-- shortened: these are fields from your Section -->
    </entry>
</data>

So both the page parameters and your newly-created entry are available to query.

Therefore the values for the options above may read:

Subject: Contact form

Sender Name: {entry/name}

Senders: {entry/email}

Recipients: youremail@domain.com

I think "Expression" is almost like a check, to see whether the email should be sent or not. For example if the Event fails you don't want to send the email. But if an entry is created successfully, you do. This value is always an Xpath expression, so don't put curly braces around. I used:

Expression: entry

Therefore if it finds an entry node, it will proceed to send the email.

The Page drop down confused me at first. I thought it referred to the page onto which the event was attached. But in reality the email reads the contents of this page to use as the body of the email. So to get this working:

a. Create a new page, e.g. "Contact form email" and enter the plain text for your email into this page

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text" encoding="UTF-8" />

<xsl:template match="data">
    Hello! This is a contact form email.
</xsl:template>

</xsl:stylesheet>

b. Return to your Template and select this page from the Page drop down.

This is fine, but not altogether useful. You may want to re-use information from your contact form inside the email.

The trick here is to pass the newly created entry ID to this new page, and use a Data Source to query your contact form section and write the data to the page. So you will need to:

c. Add an Xpath expression into the Params textfield in the Condition:

Params: {entry/@id}

d. Edit the "Contact form email" page to accept URL parameter, let's call it "id"

e. Create a Data Source such as "Contact Form by ID" to query the contact form section on System ID, with the filter value of {$id}, and attach it to your email page.

You can then modify the XSLT to use the values:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text" encoding="UTF-8" />

<xsl:template match="data">

    Dear <xsl:value-of select="//entry/name" />,

    Lorem ipsum dolor sit amet. 

    Thanks,

    Nick

</xsl:template>

</xsl:stylesheet>

The final step is to make your original Event also send the email. Modify the event (Blueprints > Components > Events) and select the Email Template from the Filter Rules selectbox.

Then make a cup of tea.

Thanks for the explanation, I've always had problems making this work...

Using 1.006 of this extension I am getting this System error:

Line 124 – The section associated with the data source Berichten could not be found.

Warning: MySQL Error (2006): MySQL server has gone away in query "INSERT INTO sm_sessions (session, session_expires, session_data) VALUES ('x', 'x', 'sym-|a:0:{}') ON DUPLICATE KEY UPDATE session = 'x', session_expires = 'x', session_data = 'sym-|a:0:{}'" in /symphony/lib/toolkit/class.mysql.php on line 400

Peeking at github, I tried version 1.010 but that also gave me an error. I forgot to save the error, but it was something with accessing a private object and Frontend datasourceprocessing.

I wonder which version to use now. And, how does one make a cup of tea?

When do you get that error?

BTW, I finally pulled your changes :)

I get that error when I try to send the contact form and when I have filled in all fields correctly. Berichten (excuse me for my Dutch) is the section and name of the datasource where all Messages are stored. The page keeps loading on submit, seems to time out, and then throws the error message above.

It might be related to the new server I just moved this website to, but I think this server should be able to handle both symphony and the email extension.

Carsten, you must have been using the unstable version, that code was added much later than 1.006.

I'm about to release a new version which does have the code that caused the problem, but also explains how to fix it.

This extension is foffing marvleous!

I’m having trouble displaying any content in the message part of the email.

I have followed the tutorial, the only thing I have not entered is the Advanced Expression part, but I thought that was just if you had more than one address.

The email gets sent, the template shows up the right data. But the message isn’t getting sent.

Important to note I am using a static message with dynamic data, and not a message that the user writes in the form.

Hey Nick,

If the email is getting sent, then it is probably a problem on the page the email is getting its content from. Do you get the desired email content when you access the email content page through your browser?

I’d also suggest taking a look at the raw source of the email; I’ve had issues with the content-type with this extension. The content might be there, but not rendered/understood by your email client.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details