Emailer to work with ICM mail server
This commit is contained in:
parent
3d9aa16334
commit
f0422177d8
|
@ -19,7 +19,6 @@ import java.io.IOException;
|
|||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by kiatrop on 28/9/2017.
|
||||
*/
|
||||
|
@ -102,6 +101,7 @@ public class ForgotPasswordServlet extends HttpServlet {
|
|||
response.sendRedirect("./error.jsp");
|
||||
|
||||
} catch (MessagingException e) {
|
||||
logger.error("Error in sending email", e);
|
||||
request.getSession().setAttribute("message", "Error sending email.");
|
||||
response.sendRedirect("./forgotPassword.jsp");
|
||||
}
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
package eu.dnetlib.openaire.usermanagement.email;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.mail.*;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Created by kiatrop on 9/10/2017.
|
||||
*/
|
||||
public class EmailSender {
|
||||
|
||||
private static String username;
|
||||
private static String password;
|
||||
private static String host;
|
||||
private static String port;
|
||||
private static String from;
|
||||
|
||||
Logger logger = Logger.getLogger(EmailSender.class);
|
||||
|
||||
public void sendEmail(String recipient, String subject, String body) {
|
||||
|
||||
// Get system properties
|
||||
Properties properties = System.getProperties();
|
||||
properties.setProperty("mail.smtp.host", host);
|
||||
properties.put("mail.smtp.port", port);
|
||||
properties.put("mail.smtp.auth", "true"); //enable authentication
|
||||
properties.put("mail.smtp.starttls.enable", "true");
|
||||
|
||||
Session session = javax.mail.Session.getInstance(properties,
|
||||
new Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// Create a default MimeMessage object.
|
||||
MimeMessage message = new MimeMessage(session);
|
||||
|
||||
// Set From: header field of the header.
|
||||
message.setFrom(new InternetAddress(from));
|
||||
|
||||
// Set To: header field of the header.
|
||||
message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
|
||||
|
||||
// Set Subject: header field
|
||||
message.setSubject(subject);
|
||||
|
||||
// For simple text setText() can be used instead of setContent()
|
||||
|
||||
// Send the actual HTML message, as big as you like
|
||||
message.setContent(body, "text/html");
|
||||
|
||||
// Send message
|
||||
Transport.send(message);
|
||||
logger.debug("Sent message successfully....\n");
|
||||
|
||||
} catch (AddressException ae) {
|
||||
logger.error("Email could not be send.", ae);
|
||||
|
||||
} catch (MessagingException me) {
|
||||
logger.error("Email could not be send.", me);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
oidc.secret = U_gLOupYu2trYIOwfxGgZkkZoOHG_zGfaViOUsXcZ7qVQuF1rcJeQYKIDX1TY3z27CIoHaqq9ht2rmAiUmBRYQ
|
||||
oidc.id = 24e83176-1312-4ba3-bc0b-ffeebea1603e
|
||||
oidc.issuer = https://aai.openminted.eu/oidc/
|
||||
oidc.home = http://rudie.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login
|
||||
webbapp.front = http://scoobydoo.di.uoa.gr:5000/reload
|
||||
|
||||
oidc.home = https://beta.services.openaire.eu/uoa-user-management/openid_connect_logi
|
||||
webbapp.front = https://beta.explore.openaire.eu/
|
||||
webbapp.front.path = /
|
||||
webbapp.front.domain = .di.uoa.gr
|
|
@ -17,6 +17,9 @@
|
|||
<!--<bean id="webexpressionHandler"-->
|
||||
<!--class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>-->
|
||||
|
||||
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"/>
|
||||
<bean class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory"/>
|
||||
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="order" value="2" />
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
log4j.rootLogger = DEBUG, R
|
||||
log4j.rootLogger = WARN, R
|
||||
|
||||
log4j.logger.eu.dnetlib = DEBUG
|
||||
log4j.logger.org.mitre.openid = DEBUG
|
||||
log4j.logger.org.springframework = DEBUG, S
|
||||
log4j.logger.eu.dnetlib = INFO
|
||||
log4j.logger.org.mitre.openid = INFO
|
||||
log4j.logger.org.springframework = INFO, S
|
||||
|
||||
log4j.additivity.org.springframework = false
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app>
|
||||
|
||||
<display-name>uoa-user-management</display-name>
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>
|
||||
|
@ -59,18 +57,6 @@
|
|||
<url-pattern>/register</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!--<servlet>-->
|
||||
<!--<servlet-name>Register2Servlet</servlet-name>-->
|
||||
<!--<display-name>Register2</display-name>-->
|
||||
<!--<servlet-class>eu.dnetlib.openaire.usermanagement.Register2Servlet</servlet-class>-->
|
||||
<!--<load-on-startup>1</load-on-startup>-->
|
||||
<!--</servlet>-->
|
||||
|
||||
<!--<servlet-mapping>-->
|
||||
<!--<servlet-name>Register2Servlet</servlet-name>-->
|
||||
<!--<url-pattern>/register2</url-pattern>-->
|
||||
<!--</servlet-mapping>-->
|
||||
|
||||
<servlet>
|
||||
<servlet-name>VerificationCodeServlet</servlet-name>
|
||||
<display-name>Verify code</display-name>
|
||||
|
|
Loading…
Reference in New Issue