Expand my Community achievements bar.

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

5 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.

Avatar

Level 2

How is this configurable for ootb Workflow "notify user via email." option?

andrija_sm_0-1669144143570.png