I'm wondering how best to go about creating a contact form that uses a select box with some options. For example, the form might have the following options and recipients:

I would like...

  • A quote (
  • Someone to call me (
  • Employment information (
  • Site/Technical support (

I am trying to port the behaviour of an existing site to Symphony, where a form will trigger sending a message, depending on the value selected in the select box.

Or, I suppose I could use JavaScript to modify the recipient when different options are selected with the select box.

What would be the best approach?

I would look at customising the email sending event to check the POST value of the select box, then set the recipient email accordingly.

Thanks, Allen. I thought that would be best, but I wasn't sure how exactly to go about setting the email recipient. It looks like I can just override the value of the $_POST values in the __trigger() method:

protected function __trigger(){
    if($_POST['fields']['subject'] == 'Request for a quote') {
        $_POST['send-email']['recipient'] = 'sales';
    elseif($_POST['fields']['subject'] == 'Please call me') {
        $_POST['send-email']['recipient'] = 'info';
    elseif($_POST['fields']['subject'] == 'Employment Information') {
        $_POST['send-email']['recipient'] = 'hr';
    elseif($_POST['fields']['subject'] == 'Site/Technical support') {
        $_POST['send-email']['recipient'] = 'support';
    include(TOOLKIT . '/events/event.section.php');
    return $result;

Yup, pretty much.

The Email Template Filter is perfectly suited for this situation, have you given it a whirl?

Thanks, brendo. I haven't had a chance to give it a whirl yet. I'm definitely going to have to give it a go.

It's a bit of a process to get it setup, hence the tutorial, but it's pretty flexible :)

I do the same thing on this form except the value of each option is the email prefix before the @ symbol, so I don't have to code any values into the event. The email is sent to:

$_POST['fields']['to'] . ''

Nick, how did you pass the email address, rather than the recipient author username?

I used the Email Templates Filter, so the email address is built dynamically.

Ah, I see. Thanks, Nick.

Any reason you didn't use the expressions Nick? ETF allows you run an XPath condition on the page XML to determine which email address should the email should be sent to.

What if i want to send a email confirmation to the user, will this work:

 <input name="etm[contato][recipient]" value="fields[email]" type="hidden" />


@duhpc: the latest version of the ETM (development branch on github) does support it in roughly the same way the email template filter does.

The version you are using right now does not allow it to prevent spam. Anyone could enter any email address there, and the email would be sent.

I have not yet released the new version of ETM as an "official" one, because I have not yet finished the documentation, and because its implementation will most likely change a bit in the next few days. However, for your simple case this should not be a problem.

If you need any help, feel free to ask in the ETM thread. That will help me build the documentation, too.

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