Wednesday, May 29, 2013

Configuring Email Notification

In order to send email from CQ, the Day CQ Mail Service needs to be configured properly.
Procedure: 1. Go to felix web console (http://<host-name>:<port>/system/console/configMgr)
2. Search for Day CQ Mail Service
3. Edit and configure as follows:
a.  The SMTP server port must be 25 or higher.
b.  The SMTP server host name must not be blank.
c.  The "From" address must not be blank. 
Screen shot:

Simple code to send an email
There are difference ways to send an email.
Method 1: Using SimpleEmail
        SimpleEmail email = new SimpleEmail();
email.addTo("", "John Doe");
email.setFrom("", "Me");
        email.setSubject("Test message");
        email.setMsg("This is a simple test of commons-email");
Method 2: Using HtmlEmail without using MessageGateway
        HtmlEmail email = new HtmlEmail();
        email.addTo("", "John Doe");
        email.setFrom("", "Me");
        email.setSubject("Test email with inline image");
        // set the html message //
        email.setHtmlMsg("<html>The apache logo - <img src=\"cid:"
        // set the alternative message
        email.setTextMsg("Your email client does not support HTML messages");
Note: We can also read smtp details from the felix console configurations instead of passing smtp details directly.

1 comment:

  1. Great article – Impressive: We think you might be interested to know more about our company. Techno Data Group helps you get your hands on world’s best class customized B2B Contact List, which can make your sales and marketing campaigns cost effective. Achieve Your Marketing Goals and Grow Your Business.
    Adobe Experience Manager Users Email & Mailing List