Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Send Newsletter through email using java

Avatar

Level 2

I am trying to send Newsletter to a set of recipients using below code

    ResourceResolver resolver = resourceResolverFactory
                .getAdministrativeResourceResolver(null);
        Session session = resolver.adaptTo(Session.class);
        PageManager pageManager = pageManagerFactory.getPageManager(resolver);
        Page page = pageManager.getPage("/content/campaigns/geometrixx/monthly_newsletter");
        NewsLetter newsletter = newsletterService.buildNewsletter(page);
        MailingList mailingList = newsletterService.createMailingList(
                "groupname", session);
        newsletter.setMailingList(mailingList);
        MailingStatus status = newsletterService.sendNewsletter(newsletter);

The problem i am facing is java code runs without any error and the status received says mail is SENT and haserror is false, but no mail is received.

Any assistance on this would be greatly appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 6

Newsletter service returns ok, but if the common SMTP setting for your CQ-instance is not set correctly, then the actual mail may not be sent.

View solution in original post

4 Replies

Avatar

Level 10

Another option you have is to write a custom Java email service as an OSGi and use that to send emails. See http://scottsdigitalcommunity.blogspot.ca/2013/08/creating-aem-applications-that-use.html

Avatar

Correct answer by
Level 6

Newsletter service returns ok, but if the common SMTP setting for your CQ-instance is not set correctly, then the actual mail may not be sent.

Avatar

Level 2

Now i am able send email, but that mail content is empty... No newsletter inside email..

Avatar

Level 2

common SMTP settings for  CQ-mail service are already set using configuration tab of OSGI console.