Expand my Community achievements bar.

com.day.cq.mailer.MailingException: Invalid mail service configuration.

Avatar

Level 2
Hi,
 
We are using the MessageGatewayService to send custom email notifications within a workflow. I've configured the SMTP details correctly and verified them in the Day CQ Mail Service configuration in ConfigMgr. However, I encounter an "Invalid mail service configuration" error when sending emails. 
 
While debugging the code, I noticed that all values are null within MessageGateway<HtmlEmail> messageGateway = messageGatewayService.getGateway(HtmlEmail.class);.The issue resolves when I restart the instance or stop and start the "Day Communique 5 Mailer" bundle (com.day.cq.cq-mailer).
 
We are using AEM 6.5 with Service Pack 6.5.17. 
 
Any help is greatly appreciated.
 
Caused by: com.day.cq.mailer.MailingException: Invalid mail service configuration.
    at com.day.cq.mailer.impl.DefaultMailService.send(DefaultMailService.java:300) [com.day.cq.cq-mailer:5.14.3.B0006]
    at com.day.cq.mailer.impl.DefaultMailService.send(DefaultMailService.java:50) [com.day.cq.cq-mailer:5.14.3.B0006]
 
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

7 Replies

Avatar

Community Advisor

@Divya_T13 

 

The issue has been reported over multiple threads with a solution to restart the bundle. 

 

Somehow we are not facing this issue.

Our config is placed under /apps/system/config/com.day.cq.mailer.DefaultMailService.config

 

In the old format

# Configuration created by Apache Sling JCR Installer
debug.email=B"true"
smtp.starttls=B"false"
oauth.flow=B"false"
smtp.host="abc.smail.com"
smtp.ssl=B"false"
from.address="abc@def.com"
smtp.port=I"25"
smtp.password="123"
smtp.user="abc@def.com"

Aanchal Sikka

Avatar

Level 2

@aanchal-sikka Restarting the bundle works. But, we'll not have permission in actual envts to do this.

Avatar

Community Advisor

Hi @Divya_T13 

Do you know when does the issue start occurring that is lets say you have started instance and its working fine. Does it start occurring after sometime or what is the event?

 

Thanks,

Nupur

Avatar

Level 2

Hi @Nupur_Jain 

In my case, I have a workflow that includes a custom process step to send email notifications. It works fine after starting or restarting the instance, or after starting and stopping the "Day Communique 5 Mailer" bundle. But, the issue occurs after some time.

Avatar

Community Advisor

Hi @Divya_T13 , The MessageGatewayService's lifecycle is container managed. If the service is fine after restarting the instance but stops working after a while, i will be looking in the bundles that is getting installed that forces a OSGI bundles refresh. Can you try the following debugging steps to confirm it that's true:
1. Make sure the Message Gateway Service is able to send emails.

2. Deploy the custom code on the instance, monitor the logs at this point to look for Service Unregister/Register events specifically the MessageGatewayService.

3. Test the Service to confirm if it broke. If not, repeat with another custom bundle.

 

Though time taking, that is the best shot at getting to the root cause. Good luck!

 

Regards,

Fani

Avatar

Level 2

Hi @Fanindra_Surat 

 

We have a configuration factory service to bind multiple config for different stakeholders. Whenever i update in one of the config instance and deploy code, I am seeing [CM Event Dispatcher (Fire ConfigurationEvent: pid=com.day.cq.mailer.DefaultMailService)] com.day.cq.mailer.impl.DefaultMailService No mail service configuration present and then email functionality stops working.