Search

Hi there, was wondering if anybody could help,

I am currently using email template manager to send out triggered emails to recipients listed within the settings of a template.

The recipients are being generated by multiple data sources so for example my recipients input field looks like this:

{//data/email-first-delegate/entry/email}, {//data/email-registration/entry/email}

(each data source only outputs one email address)

This is working absolutely fine however what I would like to happen is if the data sources outputs the same email address I would like it to only send out one email instead of one for each as the recipient receiving the same email twice is not ideal.

Any help would be great, Thanks.

I'm pretty sure there's no way to do this as an end-user of the extension, but it's probably not too involved a change in the extension code itself.

I'm assuming that the extension runs a loop on the recipient field, splitting the value by the , character.

So all you really need to do is add a check to that loop to ensure that it only runs once on unique values. I'm sure there are a few valid ways to do this, first that comes to mind is adding each processed value to a new array, and running an in_array() on the email address at the start of the loop, exiting if true.

Without knowing your PHP comfort level that may or may not be a useful suggestion…

Thanks Nathan, will give that a go.

I'd rather build a datasource with unique values. You could just output your recipient IDs from the various datasources as parameters and filter a "final recipients" datasource with these params.

@michael-e I think I understand what you're saying here, a DS chain right? How would you ensure it's a unique value? (I don't doubt that this is the best method if coming from yourself, but would like to understand it more :) )

@nathanhornby: Yes, if you build a DS chain, your last datasource won't output items twice (even if the parameters you filter on will have duplicate IDs). So if you have 2 data-sources:

  • recipients1 (param output $ds-recipients1.system-id)
  • recipients2 (param output $ds-recipients2.system-id)

And now you create a final data-source recipientsAll, filtered on the system ID with something like:

{$ds-recipients1.system-id:0},{$ds-recipients2.system-id:0}

then you won't get any double results (even if both original data-sources output the same ID).

I generally tend to use a single recipient DS.

@moonoo2:

What about Array_unique() on the above properties array?

This also sounds like a way to go, but at first sight I have no idea about downsides this might have.

@moonoo2: In other words: I know that not sending duplicate emails has been a development goal for the Email Newsletter Manager, but I am not sure about the correct behaviour for the Email Template Manager. Maybe @creativedutchmen remembers…

@michael-e sure thing, we tested this out with @RepublicofDave today and the results seemed to be correct.. further testing needed but for our purposes filtering out duplicates is all that is required so that approach is sufficient 'pending further testing' for our needs :)

Our use case is where the First registered Delegate to an event is also the primary contact when submitting a registration.... if both of these input fields share the same email address.. (A lot of submittals don't but on the rare occasions they do) we we're after a way to omit the duplication of emails being sent.

I'm actually wondering what the use case would be for sending 'in a loop' multiple emails from the same ETM template to the same user? only you guys can answer that IMO. :)

I'm actually wondering what the use case would be for sending 'in a loop' multiple emails from the same ETM template to the same user?

So do I. I just don't want to ruin a use case we both do not think of.

Thinking about it, I don't see any valid use case. I will change the ETM to include array_unique() as proposed. (You can still send to 'Bob <foo@example.com>', 'Alice <foo@example.com>' and will have two emails sent.)

ETM 7.1 has been released.

Woop!

Good call, I was wasting a lot of brain cells trying to think of a use case myself :) job done.. thanks Michael.

@michael-e a use-case might be if you switch parts of your template depending on the section the email came from, but I agree that's probably bad practice anyway.

I am totally fine with the array_unique approach.

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