GitHub PullRequestReviewCommentEvent at 2014-04-07 17:45:58
Repository: acs-aem-commons
Actor: upasanac
Payload: {"comment":{"url":"https://api.github.com/repos/Adobe-Consulting-Services/acs-aem-commons/pulls/comments/11355646","id":11355646,"diff_hunk":"@@ -0,0 +1,158 @@\n+---\r\n+layout: feature\r\n+title: Email API\r\n+description: Generic Email Service to send template based emails\r\n+date: 2013-04-06 23:39:29\r\n+thumbnail: /images/email-api/thumbnail.png\r\n+categories: features\r\n+tags: new\r\n+\r\n+---\r\n+\r\n+\r\n+## Purpose\r\n+The **EmailService** provides APIs for sending emails through a centrally configured service. \r\n+It uses an email template which is stored in the CRX repository inside  `/etc/notifications/`. \r\n+You can create author-able templates so that the developers do not need to be involved in creating and updating email templates. \r\n+\r\n+## Email API definition\r\n+\r\n+`com.adobe.acs.commons.email` \r\n+### **Class EmailService** ###\r\n+\r\n+[java.lang.Object](http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true)\r\n+-> com.adobe.acs.commons.email.EmailService\r\n+\t\r\n+ \r\n+\t boolean  | sendEmail(String templatePath, Map<String, String> emailParams, InternetAddress... recipients)  \r\n+\t boolean  | sendEmail(String templatePath, Map<String, String> emailParams, String... recipients)  \r\n+\r\n+### Method detail ###\r\n+\t\r\n+\tpublic boolean sendEmail(String templatePath, Map<String, String> emailParams, InternetAddress... recipients);\r\n+\r\n+**Description:**  \r\n+Sends an email to atleast one recipient based on the template text specified by the templatePath and replacing variables in the template text using the emailParams.\r\n+\r\n+**Parameters:**       \r\n+\r\n+1. templatePath - An absolute path of the email template in the repository. eg: /etc/notification/email/emailTemplate.txt.  \r\n+2. emailParams  - Map containing template variable [name : value] that is injected in the email.     \r\n+3. recipients   - A variable array of recipients email addresses of type InternetAddress. \r\n+\r\n+**Returns:**  \r\n+boolean  \r\n+true - if email is sent sucessfully,  \r\n+false otherwise.\r\n+\r\n+\r\n+\tpublic boolean sendEmail(String templatePath, Map<String, String> emailParams, String... recipients);\r\n+\r\n+**Description:**  \r\n+Sends an email to atleast one recipient based on the template text specified by the templatePath and replacing variables in the template text using the emailParams. This API internally calls sendEmail() method with param recipients type InternetAddress.\r\n+\r\n+**Parameters:**       \r\n+\r\n+1. templatePath - An absolute path of the email template in the repository. eg: /etc/notification/email/emailTemplate.txt.  \r\n+2. emailParams  - Map containing template variable [name : value] that is injected in the email.     \r\n+3. recipients   - A variable array of recipients email addresses of type String. \r\n+\r\n+**Returns:**  \r\n+boolean  \r\n+true - if email is sent sucessfully,  \r\n+false otherwise.\r\n+\r\n+## How to Use\r\n+\t\r\n+#### Configuring the MAIL SERVICE\r\n+The first step to sending emails through CQ is to configure the  CQ Mail Service.  To do this, log into to the OSGi Console at `{server}:{port}/system/console/configMgr ` and look for a service called **Mail Service**.\r\n+For CQ to be able to send emails, the Day CQ Mail Service needs to be properly configured. You can view the configuration in the Felix web console. \r\n+\r\n+The following constraints apply:\r\n+\r\n+- The **SMTP server port** must be 25 or higher.\r\n+- The **SMTP server host** name must not be blank.\r\n+- The **\"From\" address** must not be blank.\r\n+\r\n+Enter all of the relevant information for your current SMTP provider.  If you don't have or can't easily get SMTP set up within your organization, a Gmail account works for testing.\r\n+\r\n+Once you have the Day CQ Mail Service configured you should be able to send emails.  If, later on you run into problems with getting a null Message Gateway, you probably entered something incorrectly here.\r\n+The configuration looks as follows in the web console:\r\n+\r\n+![image]({{ site.baseurl }}/images/email-api/mail-service-config.png)\r\n+\r\n+#### Creating an Email Template \r\n+\r\n+Templates are nt:file nodes in the repository representing a text file.\r\n+The text file contains the complete email. Email headers are defined as the first lines of the file in the format Header-Name: Header-Value, one header per line. Headers supporting multiple values can thus have several header lines. The supported headers are the standard email headers.\r\n+\r\n+After the last header line put an empty line and start the email body afterwards.\r\n+The templates are simple texts files. \r\n+\r\n+Below is a sample Email Template file. All of the text in the format ${variable} will be replaced with the variable matching the name inside the brackets.  These variables are injected dynamically by this API.  \r\n+\r\n+![image]({{ site.baseurl }}/images/email-api/email-template.png)\r\n+\r\n+Once you have created the template, upload it inside `/etc/notifications` using the CQ Tools manager.\r","path":"_posts/2014-04-06-email-api.md","position":96,"original_position":96,"commit_id":"7eaf6e3949eaa7fc11dea93ef133f6a864ff12c7","original_commit_id":"7eaf6e3949eaa7fc11dea93ef133f6a864ff12c7","user":{"login":"upasanac","id":5688178,"avatar_url":"https://avatars.githubusercontent.com/u/5688178?","gravatar_id":"f519f40f0402ffba5fb07f3174cc5007","url":"https://api.github.com/users/upasanac","html_url":"https://github.com/upasanac","followers_url":"https://api.github.com/users/upasanac/followers","following_url":"https://api.github.com/users/upasanac/following{/other_user}","gists_url":"https://api.github.com/users/upasanac/gists{/gist_id}","starred_url":"https://api.github.com/users/upasanac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/upasanac/subscriptions","organizations_url":"https://api.github.com/users/upasanac/orgs","repos_url":"https://api.github.com/users/upasanac/repos","events_url":"https://api.github.com/users/upasanac/events{/privacy}","received_events_url":"https://api.github.com/users/upasanac/received_events","type":"User","site_admin":false},"body":"Added a note for this. ","created_at":"2014-04-07T17:45:58Z","updated_at":"2014-04-07T17:45:58Z","html_url":"https://github.com/Adobe-Consulting-Services/acs-aem-commons/pull/170#discussion_r11355646","pull_request_url":"https://api.github.com/repos/Adobe-Consulting-Services/acs-aem-commons/pulls/170","_links":{"self":{"href":"https://api.github.com/repos/Adobe-Consulting-Services/acs-aem-commons/pulls/comments/11355646"},"html":{"href":"https://github.com/Adobe-Consulting-Services/acs-aem-commons/pull/170#discussion_r11355646"},"pull_request":{"href":"https://api.github.com/repos/Adobe-Consulting-Services/acs-aem-commons/pulls/170"}}}}