ACS commons 5.3.0 Email service not working with AEM 6.5 | Community
Skip to main content
Level 2
June 10, 2022

ACS commons 5.3.0 Email service not working with AEM 6.5

  • June 10, 2022
  • 3 replies
  • 2630 views

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 

com.adobe.acs.commons.email.impl.EmailServiceImpl

 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
/apps/settings/notification-templates/email/default/XXX/YYY.txt

 

This email we are trying to send from a 

SlingAllMethodsServlet

But in another project which uses 

SendTemplatedEmailProcess

 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.
Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

MayurSatav
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
June 10, 2022
Level 2
June 10, 2022

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.

 

Regards,
Anil

milind_bachani
Adobe Employee
Adobe Employee
June 11, 2022

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
June 14, 2022

Hi Milind,

I have changed the template path to e.g 

/etc/notification/email/XXXX/en.txt

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.

thanks

 

milind_bachani
Adobe Employee
Adobe Employee
June 14, 2022

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.

 

Thanks,

Milind

Level 3
December 3, 2022

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
December 3, 2022

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
December 5, 2022

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.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/acs-aem-commons-email-issue-getting-emailid-in-failurelist/m-p/561205#M139628

Thanks for the reply.