com.day.cq.mailer.MailingException: Invalid mail service configuration. | Community
Skip to main content
Level 3
November 22, 2024
Question

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

  • November 22, 2024
  • 5 replies
  • 1419 views
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]
 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

5 replies

DivyaT3Author
Level 3
November 22, 2024

 

aanchal-sikka
Community Advisor
Community Advisor
November 22, 2024

@divyat3 

 

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
DivyaT3Author
Level 3
November 22, 2024

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

Nupur_Jain
Adobe Employee
Adobe Employee
November 22, 2024

Hi @divyat3 

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

DivyaT3Author
Level 3
November 22, 2024

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.

Fanindra_Surat
Community Advisor
Community Advisor
November 22, 2024

Hi @divyat3 , 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

DivyaT3Author
Level 3
November 25, 2024

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.

kautuk_sahni
Community Manager
Community Manager
February 10, 2025

@divyat3 Did you find the suggestions helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Kautuk Sahni