Clarity PPM: GEL emails using addRecipient Java method failing to deliver emails when there are multiple recipients in To and CC
search cancel

Clarity PPM: GEL emails using addRecipient Java method failing to deliver emails when there are multiple recipients in To and CC


Article ID: 222834


Updated On:


Clarity PPM SaaS


GEL script emails that have multiple recipients in the To: and CC: are not being delivered and are returned with the following error message:

A message was received from this address by our systems that had errors in the SMTPAPI header, and cannot be processed due to the following:
 - 4 duplicate cc header detected, rfc5322 states that there should be a max of 1
If you require assistance in working with the SendGrid API, please contact us at [email protected]

Note: The error messages will not be in the Clarity logs because it has bounced at the email server layer. The SENDER address in the gel script will receive the failure notice. as an attachment. 

GEL scripts can use custom Java classes to send email notifications. 
In this case, javax.mail.internet.InternetAddress and the method used within this class is addRecipient
When the addRecipient method is used, the To: and CC: headers get duplicated in the emails being sent out. 
For example, if there are 3 recipients in the To, the email header will be:

To:[email protected]
To:[email protected]
To:[email protected]

However, if  <gel:email> or <email:email> is used the header would look like:

To: [email protected];[email protected];[email protected]


On 10th Aug, the SaaS email vendor has pushed the change below to adhere to the RFC standards and therefore, emails to multiple recipients that
use the addRecipient method will fail to deliver.

Only one of each type of header is permitted.  We will no longer support duplicate headers for the following:


Below is a snippet of the GEL script used for emails which will have duplicate headers in the email and will fail

<core:catch escapeText="false" var="exception">
<core:invokeStatic className="javax.mail.Session" method="getInstance" var="mailSession">
<core:arg type="java.util.Properties" value="${props}"/>
<core:arg type="javax.mail.Authenticator" value="${clarity_auth}"/>
<core:set value="${mailSession.setDebug(debug)}" var="void"/>
<core:new className="javax.mail.internet.MimeMessage" var="message">
<core:arg type="javax.mail.Session" value="${mailSession}"/>
<core:set value="${V_EMAIL_SUBJECT} ${V_PROJ_CODE}" var="v_Email_Full_Subject"/>
<core:set value="${message.setSubject(v_Email_Full_Subject)}" var="void"/>
<core:new className="javax.mail.internet.InternetAddress" var="Sender">
<core:arg type="java.lang.String" value="${Sender}"/>
<core:set value="${message.setFrom(Sender)}" var="void"/>
<core:invokeStatic className="java.lang.Class" method="forName" var="rt">
<core:arg type="java.lang.String" value="javax.mail.Message$RecipientType"/>
<core:set value="${rt.getField('TO')}" var="rt"/>
<core:set value="${rt.TO}" var="rt"/>
<core:forEach items="${v_BUPS_Email}" var="thisRecipient">
<core:new className="javax.mail.internet.InternetAddress" var="sendToEmail">
<core:arg type="java.lang.String" value="${thisRecipient}"/>
<core:set value="${message.addRecipient(rt, sendToEmail)}" var="void"/>


The email code in the GEL script will have to be modified to use the following tags:


The other option is to use setRecipient Java method instead of the addRecipient method. 

Additional Information