From 3eef63bd0c0347dccfd5024f75f53f1f82b6d98d Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Thu, 24 Mar 2016 14:47:09 +0000 Subject: [PATCH] moved emailnotifcation to portal Manager git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/invites-common-library@126249 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../portal/invites/EmailNotification.java | 103 ------------------ .../gcube/portal/invites/InvitesManager.java | 12 +- 2 files changed, 3 insertions(+), 112 deletions(-) delete mode 100644 src/main/java/org/gcube/portal/invites/EmailNotification.java diff --git a/src/main/java/org/gcube/portal/invites/EmailNotification.java b/src/main/java/org/gcube/portal/invites/EmailNotification.java deleted file mode 100644 index 8259278..0000000 --- a/src/main/java/org/gcube/portal/invites/EmailNotification.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.gcube.portal.invites; - -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; - - -/** - * A class for sending email - * - * @author M. Assante - * - */ -public class EmailNotification { - /** - * The sender of the email - */ - private String emailSender; - - /** - * The recipients of the email - */ - private String emailrecipients[]; - - /** - * Email's subject - */ - private String emailSubject; - - /** - * Email's body message - */ - private String emailBody; - - private String portalName; - - /** Logger */ - private static Logger _log = LoggerFactory.getLogger(EmailNotification.class); - - /** - * Class's constructor - * - * @param sender - * @param recipients - * @param subject - * @param body - */ - public EmailNotification(String sender, String recipients[], String subject, String body) { - this.emailSender = PortalContext.getConfiguration().getSenderEmail(); - this.emailrecipients = recipients; - this.emailSubject = subject; - this.emailBody = body; - this.portalName = PortalContext.getConfiguration().getGatewayName(); - } - - 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(emailSender, portalName); - mimeMessage.setHeader("Content-Type", "text/html; charset=UTF-8"); - mimeMessage.setFrom(from); - - // EMAIL RECIPIENTS - for (int i=0; i
"); body.append("" + scope+""); body.append("

"); - body.append("

"); - body.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"+ - " 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."); - body.append("

"); - + String[] allMails = new String[adminEmails.size()]; - adminEmails.toArray(allMails); - - EmailNotification mailToAdmin = new EmailNotification("no-reply@d4science.org", allMails , "[" + gatewayName + "] - Sent Invitation", body.toString()); + EmailNotification mailToAdmin = new EmailNotification(allMails , "[" + gatewayName + "] - Sent Invitation", body.toString()); mailToAdmin.sendEmail(); }