Search code examples
aemjcrjakarta-mailcrx

"Illegal address in String" email template in CQ5 javax.mail


Working on a customised email template in CQ5, I have created in following text file under etc/notification. The workflow is triggered when a form is filled in by the user.

From: Order Brochure <[email protected]>
To: ${payload.email}
CC:
Subject: Order Brochures Confirmation ${payload.BrochureID}

Dear ${payload.Name},

Thank you for your Brochure Order, your reference is ${payload.orderBrochureID}.
Your email address is {$payload.email}.

Everything in this template works fine, except for the "To: ${payload.email}". Even the "Your email address is {$payload.email}" part displays the user inputted email fine. It also works if I input a static email address in "To:".

What am I doing wrong here? Below is the error in logs

Process execution resulted in an error:
javax.mail.internet.AddressException: Illegal address in string ``''
com.day.cq.workflow.WorkflowException: javax.mail.internet.AddressException: Illegal 
address in string ``''

Solution

  • Remove the "CC:" it's attempting to parse the email address for this header and it's a null.

    When you're dealing with these types of problems when the error is occurring within a CQ library. I recommend using a custom logger to assist with the troubleshooting.

    Details of logging can be found at Logging - docs.day.com

    Here's an example OSGi log configuration for your issue.

    Logging Example