Send Newsletter through email using java | Community
Skip to main content
October 16, 2015
Solved

Send Newsletter through email using java

  • October 16, 2015
  • 4 replies
  • 1543 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ove_Lindström

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.

4 replies

smacdonald2008
October 16, 2015

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

Ove_LindströmAccepted solution
October 16, 2015

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.

AjitAdobeAuthor
October 16, 2015

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

AjitAdobeAuthor
October 16, 2015

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