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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

cq.mailer.DefaultMailService : RestAPI integration

Avatar

Level 1

Could I integrate an Rest full end-point in cq.mailer.DefaultMailService.

this is because, i don't have an SMTP server, but rather API end point to connect. 

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@tvnavinkumar1980,

Yes definitely, you can make java HttpRequest from OSGI services, sling servlet, sling models, etc... 

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.my-site/mail"))
        .POST(HttpRequest.BodyPublishers.ofString(requestBody))
        .build();

 

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

@tvnavinkumar1980,

Yes definitely, you can make java HttpRequest from OSGI services, sling servlet, sling models, etc... 

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.my-site/mail"))
        .POST(HttpRequest.BodyPublishers.ofString(requestBody))
        .build();

 

Avatar

Level 1
Hi @BrianKasingli, thanks. In this case, i would directly be consuming an API end point, thus cq.mailer.DefaultMailService. wont be required to be used right?

Avatar

Community Advisor
Thats correct, you can send a request to your 3rd party API server to handle email sendouts without using the AEM out of the box cq.mailer.DefaultMailService.