Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

MessageGateway is coming as null

Avatar

Avatar
Validate 1
Level 2
tkar-75R6hp
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
tkar-75R6hp
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
tkar-75R6hp
Level 2

02-03-2017

Hi Friends,

I am trying to send email in participant step. I have written a email service which uses the Message Gateway to send emails.

But MessageGateway<Email> messageGateway = this.messageGatewayService.getGateway(Email.class); this line is giving messageGateway as null.

I went through a number of posts and everywhere it is mentioned that if the SMTP details are not mentioned properly in Day Cq Mail service then it comes as null.

But I have configured it properly because if I select the senEmail checkbox in the dynamic step then AEM is able to send default emails using this. So I am sure SMTP is not something which can be at fault. Do we need something else also so that the messageGateway doesnot come as null. I am using AEM 6.1 SP3.

Thanks,

Tushar

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

06-03-2017

Here is video so you can watch all the steps. 

https://www.youtube.com/watch?v=9Ztc9hBbrwg&feature=youtu.be

Also - try on a fresh install of AEM. There may be some missing services or other mis-configured services. 

Answers (9)

Answers (9)

Avatar

Avatar
Give Back 10
Level 3
anjali_biddanda
Level 3

Likes

20 likes

Total Posts

86 posts

Correct Reply

8 solutions
Top badges earned
Give Back 10
Ignite 1
Validate 10
Validate 1
Give Back 5
View profile

Avatar
Give Back 10
Level 3
anjali_biddanda
Level 3

Likes

20 likes

Total Posts

86 posts

Correct Reply

8 solutions
Top badges earned
Give Back 10
Ignite 1
Validate 10
Validate 1
Give Back 5
View profile
anjali_biddanda
Level 3

09-06-2021

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.

Avatar

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct Reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct Reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
Feike_Visser1
Employee

06-03-2017

Now check via services (/system/console/services), find the component-id and check on the component on status.

Avatar

Avatar
Validate 1
Level 2
tkar-75R6hp
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
tkar-75R6hp
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
tkar-75R6hp
Level 2

06-03-2017

Hi,

I am seeing something like below

     
Reference messageGatewayService

["Unsatisfied","Service Name: com.day.cq.mailer.MessageGatewayService","Cardinality: 1..1","Policy: static","Policy Option: reluctant","No Services bound"]

Could you please let me know why this could be coming like this.

Thanks,

Tushar

Avatar

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct Reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct Reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
Feike_Visser1
Employee

06-03-2017

Via /system/console/components, search your component. Then you can see why references are not found

Avatar

Avatar
Validate 1
Level 2
tkar-75R6hp
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
tkar-75R6hp
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
tkar-75R6hp
Level 2

06-03-2017

How can I check in /system/console why messageGatewayService.getGateway(HtmlEmail.class) gives me null??

Avatar

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct Reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct Reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
Feike_Visser1
Employee

04-03-2017

What do you see at the component in /system/console?

There you can see the reason why a reference can't be found

Avatar

Avatar
Validate 1
Level 2
tkar-75R6hp
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
tkar-75R6hp
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
tkar-75R6hp
Level 2

04-03-2017

Hi Scott,

I have tried even that and still the MessageGateway comes null. I know the smtp config is correct as the default emails from Aem are generating fine.

Avatar

Avatar
Validate 1
Level 2
tkar-75R6hp
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
tkar-75R6hp
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
tkar-75R6hp
Level 2

03-03-2017

I have added that dependency already, also as I have mentioned earlier if I use aem's send email functionality in the participant step the default email does get generated which ascertains the fact that my SMTP details are working fine.

The only issue I am facing is the Message Gateway coming as null. I wanted to know is this a bug with AEM 6.1 sp2 that we cannot send email through our customized way i.e. using MessageGateway.

Thanks for any help.

Avatar

Avatar
Validate 25
MVP
Ratna_Kumar
MVP

Likes

158 likes

Total Posts

755 posts

Correct Reply

134 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile

Avatar
Validate 25
MVP
Ratna_Kumar
MVP

Likes

158 likes

Total Posts

755 posts

Correct Reply

134 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile
Ratna_Kumar
MVP

03-03-2017

Hi Tushar,

Please check this article which discusses sending email messages using MessageGateway service:
//https://helpx.adobe.com/experience-manager/using/creating-custom-aem-workflow-steps.html

Also, add this dependency in your POM(According to the article)

<dependency> 
    <groupId>com.day.cq</groupId>
    <artifactId>cq-mailer</artifactId>
    <version>5.6.2</version> 
    <scope>provided</scope> 
</dependency>

It worked for me many times and you need to configure Email properly in configuration manager.

In order to configure properly, you need to check this excellent article which tells how to configure the email:: http://versatileankur.blogspot.in/2016/04/mailing-issue-in-aem-with-gmail-smtp.html

Hope this helps!!

~ Ratna.