diff --git a/pom.xml b/pom.xml
index 22ea4c7..e2e446a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,6 +29,17 @@
UTF-8
UTF-8
+
+
+
+ org.gcube.distribution
+ maven-portal-bom
+ LATEST
+ pom
+ import
+
+
+
javax.servlet
@@ -42,6 +53,11 @@
2.0
provided
+
+ com.sun.mail
+ javax.mail
+ provided
+
com.liferay.portal
portal-service
@@ -55,26 +71,24 @@
provided
- com.liferay.portal
- util-bridges
- ${liferay.version}
- provided
-
-
- com.liferay.portal
- util-taglib
- ${liferay.version}
- provided
-
+ com.liferay.portal
+ util-bridges
+ ${liferay.version}
+ provided
+
+
+ com.liferay.portal
+ util-taglib
+ ${liferay.version}
+ provided
+
org.slf4j
slf4j-log4j12
- 1.6.4
org.slf4j
slf4j-api
- 1.6.4
diff --git a/src/main/java/org/gcube/common/portal/mailing/EmailNotification.java b/src/main/java/org/gcube/common/portal/mailing/EmailNotification.java
new file mode 100644
index 0000000..1f4828e
--- /dev/null
+++ b/src/main/java/org/gcube/common/portal/mailing/EmailNotification.java
@@ -0,0 +1,94 @@
+package org.gcube.common.portal.mailing;
+
+import java.util.Date;
+import java.util.Properties;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.gcube.common.portal.PortalContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author Massimiliano Assante
+ *
+ */
+public class EmailNotification {
+ private static Logger _log = LoggerFactory.getLogger(EmailNotification.class);
+ /**
+ * The sender of the email
+ */
+ private static final String EMAIL_SENDER = PortalContext.getConfiguration().getSenderEmail();
+ private static final String PORTAL_NAME = PortalContext.getConfiguration().getGatewayName();
+ /**
+ * The recipients of the email
+ */
+ private String emailrecipients[];
+ /**
+ * Email's subject
+ */
+ private String emailSubject;
+ /**
+ * Email's body message
+ */
+ private StringBuffer emailBody;
+ /**
+ * @param recipients
+ * @param subject
+ * @param body
+ */
+ public EmailNotification(String recipients[], String subject, String body) {
+ emailrecipients = recipients;
+ emailSubject = subject;
+
+ emailBody = new StringBuffer(body);
+ emailBody.append("")
+ .append("
")
+ .append("WARNING / LEGAL TEXT: This message is intended only for the use of the individual or entity to which it is addressed and may contain ")
+ .append("information which is privileged, confidential, proprietary, or exempt from disclosure under applicable law. If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, you are strictly prohibited from disclosing, distributing, copying, or in any way using this message.")
+ .append("If you have received this communication in error, please notify the and destroy and delete any copies you may have received.")
+ .append("
");
+ }
+
+ public void sendEmail() {
+ Properties props = System.getProperties();
+ String mailServiceHost = "localhost";
+ props.put("mail.smtp.host", mailServiceHost);
+ String mailServicePort = "25";
+ props.put("mail.smtp.port", mailServicePort);
+ Session session = Session.getDefaultInstance(props, null);
+ session.setDebug(true);
+ Message mimeMessage = new MimeMessage(session);
+
+ try {
+ // EMAIL SENDER
+ Address from = new InternetAddress(EMAIL_SENDER, PORTAL_NAME);
+ mimeMessage.setHeader("Content-Type", "text/html; charset=UTF-8");
+ mimeMessage.setFrom(from);
+
+ // EMAIL RECIPIENTS
+ for (int i=0; i