1

I am trying to build a multi enquiry form i which the same message plus some custom data is sent to multiple email addresses.

The email addresses and custom data are retrieved from existing entries.

My strategy so far has been to create the form like so; (the {exp:remember_me} tag simply provides a pipe delimited list of entry IDs - this bit works fine.

{exp:postmaster:email_form:open 
      action="/favourites/enquiry"
   method="post"
   field="email"
   data_field="data"
  }


   {exp:channel:entries channel="properties" entry_id="{exp:remember_me:get}" parse="inward"}

    <input type="text" name="email[entry_id]" value="{email}" />
    <input type="test" name="data[entry_id][to_name]" value="{author}" />
    <input type="text" name="data[entry_id][property-ref]" value="{property-ref}" />
    <input type="text" name="data[entry_id][title]" value="{title}" />
   {/exp:channel:entries}

    <p><label for="name">Name</label><input class="text" type="text" name="from_name" value="" id="name"></p>

    <p><label for="phone1">Telephone</label><input class="text" type="text" name="from_phone1" id="phone1"></p>


    <p><label for="email">Email<span class="req">*</span></label><input type="text" name="from_email" value="" id="email"></p>

    <p><label for="date_from">Date from</label><input class="datepicker" type="text" name="date_from" id="date_from"> <label for="date_to">Date to</label><input class="datepicker" type="text" name="date_to" id="date_to"></p>

    <p><label for="number_in_group">Number in your group</label><input type="text" name="number_in_group" id="number_in_group"></p>

    <p><label for="message">Message<span class="req">*</span></label><textarea name="message" id="message" value="" rows="12" cols="40"></textarea></p>


   <button type="submit">Submit</button>

  {/exp:postmaster:email_form:open}

This certainly triggers an email for each entry but I can only get them to send if I hardcode a recipient email address into the hook set up and I need to use the email field from each entry.

In addition I am also unable to include any of the custom data or form data within the emails. As I understand the documentation I believe I simply need to do something like this;

<table cellpadding="4" border="0">
<tr>
<td colspan="2"><b>Property enquiry from Big Holiday House</b></td>
</tr>

<tr><td><b>From</b></td><td>{from_name}</td></tr>
<tr><td><b>Email</b></td><td>{from_email}</td></tr>
<tr><td><b>Phone</b></td><td>{from_phone1}</td></tr>
<tr><td><b>Property Ref</b></td><td>{property_ref}</td></tr>
<tr><td><b>Property</b></td><td>{property_name}</td></tr>
<tr><td><b>No. in group</b></td><td>{number_in_group}</td></tr>
<tr><td><b>Date from</b></td><td>{date_from}</td></tr>
<tr><td><b>Date to</b></td><td>{date_to}</td></tr>
<tr><td valign="top"><b>Message</b></td><td>{message}</td></tr>
</table>

However, none of the tags get parsed - I just get the tag names in the email received.

I'm clearly really doing something wrong here and not understanding some fundamental aspect of using Postmaster.

How do I do it?

1 Answer 1

3

Your fundamentals are correct, you are just getting hung up on the details. A couple issues:

1) The following is incorrect:

email[entry_id] data[entry_id][some_var]

The following is correct:

email[0][] data[0][some_var]

In the context of a channel entries loop, you should do it this way:

<input type="hidden" name="email[{count}][]" value="[email protected]" />
<input type="hidden" name="data[{count}][your_custom_var_1]" value="1" />
<input type="hidden" name="data[{count}][your_custom_var_2]" value="2" />

To be clear, this would go inside your channel entries loop and the idea is to build a multiple dimensional array that matches up by the first index.

2) When parsing any variable within a hook, always prefix the variable with hook:. So your template should be:

<table cellpadding="4" border="0">
<tr>
<td colspan="2"><b>Property enquiry from Big Holiday House</b></td>
</tr>

<tr><td><b>From</b></td><td>{hook:from_name}</td></tr>
<tr><td><b>Email</b></td><td>{hook:from_email}</td></tr>
<tr><td><b>Phone</b></td><td>{hook:from_phone1}</td></tr>
<tr><td><b>Property Ref</b></td><td>{hook:property_ref}</td></tr>
<tr><td><b>Property</b></td><td>{hook:property_name}</td></tr>
<tr><td><b>No. in group</b></td><td>{hook:number_in_group}</td></tr>
<tr><td><b>Date from</b></td><td>{hook:date_from}</td></tr>
<tr><td><b>Date to</b></td><td>{hook:date_to}</td></tr>
<tr><td valign="top"><b>Message</b></td><td>{hook:message}</td></tr>
</table>
5
  • OK I've set it up as you suggest but still no joy. The tags in the message aren't parsed. Also, and this is weird, the {count} variable only returns "1" for each pass through the loop but if I put the entries loop OUTSIDE the postmaster tags then it works as it should and I get incremented values.
    – foamcow
    Commented Oct 28, 2013 at 22:12
  • You are right. This is a parse order issue. What if you replace {count} with {entry_id}? Commented Oct 28, 2013 at 23:17
  • The emails are triggered but the message still contains {hook:my_field} rather than the form data. I can only get anything to send by hardcoding an email in the To email field of the hook setup - if I try to use the actual email data from the form I get a Mandrill 500 error - presumably because it's using the tag instead of an email address.
    – foamcow
    Commented Oct 28, 2013 at 23:41
  • Ok, I am going to look into this in detail today and figure out the issue. Last time I tested this stuff, it worked 100% as I built this feature directly for another user. Commented Oct 29, 2013 at 15:09
  • The new version you sent to me and the help you gave me here has sorted the problem. Many thanks.
    – foamcow
    Commented Oct 29, 2013 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.