I've configured the Day Email Server with my Gmail email, which works because I am receiving workflow emails via this Gmail account, so the configuration is correct.
But I am trying to send a campaign email newsletter and the MessageGatewayService always comes back with null.
In my class I reference the service:
public static MessageGatewayService messageGatewayService;
And then want to retrieve it via:
MessageGateway messageGateway = messageGatewayService.getGateway(HtmlEmail.class);
I found that quite some people have had the same issue but I couldn't find any solutions.
Anyone have an idea what is going wrong?
Any help is very appreciated!
Solved! Go to Solution.
For testing purposes - do you have another email server to test with. I have never had an issue with MessageServiceGateway, but I am wondering if there is an issue with GMail SMTP server.
I'm trying with the code in that article. I'm using AEM 6.1 and used my gmail account for smtp configuration. For me, the MessageGateway is not null but it still doesn't send email, it doesn't throw any error either. Wondering how do I debug this further?
Thanks for your help!
@alexandrad27705 Restarting the com.day.cq.cq-mailer bundle in the environment was the solution that worked for me.
The MessageGatewayService contains a hashSet of gateways. If you delete or move your Day CQ Mail Service configuration, a new gateway is added to the hashSet. The messageGatewayService.getGateway() only retrieves one DefaultMailService from the hashSet, and it could be one with cfg null inside, although there exists one configured correctly. Only way to clean this up is by restarting the bundle.
Any subsequent updates to theDefaultMailService config work fine. This only happens when you delete/move your config in your environment.