Difference between revisions of "Portal Mailing API"

From Gcube Wiki
Jump to: navigation, search
(Created page with "__FORCETOC__ === Introduction === The gCube Portal Manager is a component all portlets need to use to get the context where they are running into. Moreover, passing an HttpSe...")
 
(Example of Email Sending)
 
(One intermediate revision by the same user not shown)
Line 20: Line 20:
 
...
 
...
  
 +
/**
 +
* @param recipient an email address
 +
* @param subject the subject of your email
 +
* @param body the body of your email
 +
*/
 
EmailNotification email2Send = new EmailNotification(String recipient, String subject, String body, HttpServletRequest httpServletRequest);
 
EmailNotification email2Send = new EmailNotification(String recipient, String subject, String body, HttpServletRequest httpServletRequest);
  
or  
+
//or  
  
 +
/**
 +
* @param recipients a list of email addresses
 +
* @param subject the subject of your email
 +
* @param body the body of your email
 +
*/
 
EmailNotification(List<String> recipients, String subject, String body, HttpServletRequest httpServletRequest);
 
EmailNotification(List<String> recipients, String subject, String body, HttpServletRequest httpServletRequest);
  
then
+
//then
  
 
email2Send.sendEmail();
 
email2Send.sendEmail();

Latest revision as of 17:11, 3 May 2016

Introduction

The gCube Portal Manager is a component all portlets need to use to get the context where they are running into. Moreover, passing an HttpServletRequest object to its methods, you can also use it for sending emails on behalf of the portal you are using:

Maven Dependency

In order to use it in your project, add the following dependency to the project's pom.xml file

<dependency>
	<groupId>org.gcube.common.portal</groupId>
	<artifactId>portal-manager</artifactId>
	<scope>provided</scope>
</dependency>

Example of Email Sending

import org.gcube.common.portal.mailing;
import javax.servlet.http.HttpServletRequest;
...
 
/**
 * @param recipient an email address
 * @param subject the subject of your email
 * @param body the body of your email
 */
EmailNotification email2Send = new EmailNotification(String recipient, String subject, String body, HttpServletRequest httpServletRequest);
 
//or 
 
/**
 * @param recipients a list of email addresses
 * @param subject the subject of your email
 * @param body the body of your email
 */
EmailNotification(List<String> recipients, String subject, String body, HttpServletRequest httpServletRequest);
 
//then
 
email2Send.sendEmail();