1

How can I send a gel:email to multiple recipients? I have records with 3 email addresses in each and I want to send the same email to all 3.

This is my current code:

<core:forEach items="${getDetails.rows}" var="row">
    <core:set value="${row.Manager_Email}" var="manager" />
    <core:set value="${row.Delivery_Manager_Email}" var="deliveryManager" />
    <core:set value="${row.Director_Email}" var="director" />

    <core:choose>
        <core:when test="${status == 1}">
            <gel:email from="Clarity_Do-Not-Reply@gov.nl.ca" fromName="Clarity Administrator" to="${manager};${deliveryManager};${director}" subject="Notification: Project is due to finish within 7 days">

I've tried that and:

to="${manager;deliveryManager;director}"

Neither seem to work. The doc says they can be split with the ; but it doesn't seem to be working. What am I doing wrong?

doodlebob
  • 65
  • 7

2 Answers2

1

This approach that was in your original script example is the correct way to do it: to="${manager};${deliveryManager};${director}"

That is, using a single delimiter type (semi-colon in this case) to separate each evaluated variable value.

The style from your second attempt definitely will not work as ${manager;deliveryManager;director} is not a valid JEXL expression.

There are additional points to be aware of, such as:

  1. Each of the values in the to attribute should not have anything else that can be mistaken for another delimiter type (e.g. no spaces or commas), as you may not mix and match.
  2. Only use the email address directly, meaning some.one@somedomain.com and don't use forms like "One, Some" <some.one@somedomain.com>
  3. Make sure none of the email addresses are duplicated in the list. Every address must be unique. As mentioned in the answer provided by @coda, you can filter duplicates out with some extra GEL or you can put the logic into your query (the row source) to de-duplicate.
  4. If this is running in a SaaS environment, make sure none of the user addresses you are picking up are among the defaults for some built-in user accounts like username@mailserver.com or similar, as they have resulted in emails being filtered out before sending.
topdog
  • 377
  • 1
  • 7
0

Does it work with just one of them? I would start and establish that the mail server works in this environment. Choose one of those variables and print it out. If it's not what you are expecting then fix your query or wherever you are getting those bound variables. If it is correct then remove the other two recipients and establish that you can send an email successfully to just one of the recipients. If that works then continue troubleshooting.

If it doesn't work then you may discover that your mail server does not allow relaying, unauthenticated services or sending mail from a non-existent email account. You can start checking those things.

One of the issues with both the GEL email tag and the CORE email tag is that it doesn't support including the same email address twice. If you check your project you might find that the same resource is listed as both delivery manager and manager or director, etc. This is a problem for the tag.

You can get around this by placing all recipients into a data structure that doesn't allow duplicates (like a hash map/set) and then iterate them out back into a semi colon delimited String.

There are probably lots of examples of this type of thing on regoXchange, a huge repository of free GEL scripts and Clarity related customizations and development.

Coda
  • 387
  • 2
  • 9