Portal Mailing API

From Gcube Wiki
Jump to: navigation, search

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();