Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

ACS commons 5.3.0 Email service not working with AEM 6.5


Level 2

Hi All,
We are trying to upgrade our acs-commons package from 4.3.2 to 5.3.0 for our AEM6.5 instance.  All environments are managed by Adobe managed services.  In testing, most of the things worked fine except the email service for one of our projects.  It throws this error:

Mail template path [ " + templatePath + " ] could not resolve to a valid template

I can see that it is coming from this class 


 If I downgrade to the previous package it starts working again.  It should use acs-commons-email-service but when I tried to print the user to see what is happening, it says anonymous user.
I have checked acs-commons-email-service and even anonymous/everyone has access to the email template path which is


This email we are trying to send from a 


But in another project which uses 


 which internally uses same email service, we do not have any issue and emails are going fine.
Please help if someone upgraded to 5.3.0 on AEM 6.5.

9 Replies


Level 2

Hi Mayur, 
Yes, I have checked this thread and checked the permissions as well.  That template has read permission even for anonymous and acs-commons-email-user as well.




Employee Advisor

Hi @AnilKumarUoS ,

I suspect it to be issue with permission only but since you have already checked it, I would suggest you to give a try by putting the email template to /etc instead of /apps and replace the templatePath in code and then try to execute the code.

Let me know if that helps, thanks.


Level 2

Hi Milind,

I have changed the template path to e.g 


Now, I do not get that error anymore but still, emails are not going. 
I am trying to understand which user is being used by my servlet for sending emails.  So, I am trying to print the user name and I am getting anonymous.  Ideally, it should be acs-commons-email-service user.

If I try to enforce in the code to use acs-commons-email-service user then it throws login exception.

final ResourceResolver resolver = request.getResourceResolver();

if(resolver == null){
log.debug("resolver is null");
} else {
log.info("resolver is NOT null");
Session session = resolver.adaptTo(Session.class);

String userId = session.getUserID();

log.info("USER ID :--" + userId);


The code above is an old code and used to work fine with acs-commons 4.3.2.  I am just trying to print the username (hitting from dispatcher, if logged in publish and testing there in same browser then it picks that logged in user which we do not want so hitting from dispatcher)

 However, if I try to enforce something like this:

// Map for service user details
Map<String, Object> xmlReaderMap = new HashMap<>();
xmlReaderMap.put(ResourceResolverFactory.SUBSERVICE, "acs-commons-email-service");

// Getting ResourceResovler
ResourceResolver resolver = null;
Session session = null;
try {
resolver = resourceResolverFactory.getServiceResourceResolver(xmlReaderMap);
} catch (LoginException e) {
log.error("LoginException " + e.getCause());


then I get LoginException, root cause null.

It had all worked well when I reverted back to old pkg of acs-commons 4.3.2 and started receiving emails but today facing issues with that too. So, not sure what is going on.




Employee Advisor

Hi @AnilKumarUoS ,


My doubt was right, since you were unable to access resources under /apps, but were able to access resources under /etc means the user used is anonymous. Because, anonymous had access on /etc but not on /apps.

The next thing I would suggest to have a SERVICE-USER created for purpose of fetching template and sending email.

once user is created you need to create a mapping in config and also give user relevant access in the repo. 

A video reference is here on service-users : https://www.youtube.com/watch?v=ZaV-JvgbFTc&t=8s


Do let me know in case you have further concerns.





Level 2

Thanks, Milind for your suggestion of moving the template under /etc.  It all started working once I restarted the instance.  You mentioned that by default, anonymous/everyone has read permission on /etc but I do not see any read permission on either /etc or that email template but it works for sure.

Regarding the service user, I was trying with a service user for that specific bundle and checked binding under user mapper config and permissions too from /useradmin.  Everything looked fine but I was still getting this error:

LoginException: Cannot derive user name for bundle <bundleName> [640] and sub service <serviceName>

I tried creating a new one, mapped it, and assigned permissions.  Now, see the logs:

2022-06-15 12:16:01.075 INFO [<MyclassName>] MailFeedbackServlet ::>> USER ID :--<Getting userID> - GOOD
2022-06-15 12:16:01.079 INFO [<MyclassName>] MailFeedbackServlet >> sendFeedback :: template path-->> /apps/settings/notification-templates/email/default/XX/YY.txt - GOOD
2022-06-15 12:16:01.083 ERROR [<MyclassName>] Exception: e.getMessage()-->Mail template path [/apps/settings/notification-templates/email/default/XX/YY.txt ] could not resolve to a valid template

 I have got the fix by moving template to /etc but good to know why existing/newly added system user do not work/give error.  This code used to work fine without using any service user before upgrading ACS commons package.
Thanks for your help on this.  Much appreciated.


Level 3

Hi @AnilKumarUoS @milind_bachani @MayurSatav

getting the same issue and added all the things as per your suggestion but still not getting email and for your information send email method is returning recipient email I’d, but ideally it should return the empty response if everything is works fine.

and for me this functionality is urgent please le me know if you guys can help here.


Level 2

check in the logs if you are getting the correct service user.  For me, it was somehow permissions related.  Moving the template under /etc resolved the issue for me.


Level 3

Hi @AnilKumarUoS

I am getting admin in my local and after that I checked the permission admin has all the permission and also I moved my template to etc folder still not getting the mail. We have by default acs-commons-email-service service user in cofigMgr . Do I need to create a new one and provide the permission. Could you please guide me?

I have raised a question also and below is the url.


Thanks for the reply.