use of org.springframework.mail.SimpleMailMessage in project spring-boot-admin by codecentric.
the class MailNotifier method doNotify.
@Override
protected void doNotify(ClientApplicationEvent event) {
EvaluationContext context = new StandardEvaluationContext(event);
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(to);
message.setFrom(from);
message.setSubject(subject.getValue(context, String.class));
message.setText(text.getValue(context, String.class));
message.setCc(cc);
sender.send(message);
}
use of org.springframework.mail.SimpleMailMessage in project perun by CESNET.
the class Utils method sendPasswordResetConfirmationEmail.
/**
* Sends email to user confirming his password was changed.
*
* @param user user to send notification for
* @param email user's email to send notification to
* @param namespace namespace the password was re-set
* @throws InternalErrorException
*/
public static void sendPasswordResetConfirmationEmail(User user, String email, String namespace) throws InternalErrorException {
// create mail sender
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("localhost");
// create message
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(email);
message.setFrom(BeansUtils.getCoreConfig().getMailchangeBackupFrom());
String instanceName = BeansUtils.getCoreConfig().getInstanceName();
message.setSubject("[" + instanceName + "] Password reset in namespace: " + namespace);
// get validation link params
String i = cipherInput(String.valueOf(user.getId()), false);
String m = cipherInput(namespace, false);
// Build message
String text = "Dear " + user.getDisplayName() + ",\n\nyour password in namespace \"" + namespace + "\" was successfully reset." + "\n\nThis message is automatically sent to all your email addresses registered in " + instanceName + " in order to prevent malicious password reset without your knowledge.\n\n" + "If you didn't request / perform password reset, please notify your administrators and support at " + BeansUtils.getCoreConfig().getMailchangeBackupFrom() + " to resolve this security issue.\n\n" + "Message is automatically generated." + "\n----------------------------------------------------------------" + "\nPerun - Identity & Access Management System";
message.setText(text);
mailSender.send(message);
}
use of org.springframework.mail.SimpleMailMessage in project perun by CESNET.
the class Utils method sendValidationEmail.
/**
* Send validation email related to requested change of users preferred email.
*
* @param user user to change preferred email for
* @param url base URL of running perun instance passed from RPC
* @param email new email address to send notification to
* @param changeId ID of change request in DB
* @throws InternalErrorException
*/
public static void sendValidationEmail(User user, String url, String email, int changeId) throws InternalErrorException {
// create mail sender
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("localhost");
// create message
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(email);
message.setFrom(BeansUtils.getCoreConfig().getMailchangeBackupFrom());
String instanceName = BeansUtils.getCoreConfig().getInstanceName();
message.setSubject("[" + instanceName + "] New email address verification");
// get validation link params
String i = Integer.toString(changeId, Character.MAX_RADIX);
String m = Utils.getMessageAuthenticationCode(i);
try {
// !! There is a hard-requirement for Perun instance
// to host GUI on same server as RPC like: "serverUrl/gui/"
URL urlObject = new URL(url);
// use default if unknown rpc path
String path = "/gui/";
if (urlObject.getPath().contains("/krb/")) {
path = "/krb/gui/";
} else if (urlObject.getPath().contains("/fed/")) {
path = "/fed/gui/";
} else if (urlObject.getPath().contains("/cert/")) {
path = "/cert/gui/";
}
StringBuilder link = new StringBuilder();
link.append(urlObject.getProtocol());
link.append("://");
link.append(urlObject.getHost());
link.append(path);
link.append("?i=");
link.append(URLEncoder.encode(i, "UTF-8"));
link.append("&m=");
link.append(URLEncoder.encode(m, "UTF-8"));
link.append("&u=" + user.getId());
// Build message
String text = "Dear " + user.getDisplayName() + ",\n\nWe've received request to change your preferred email address to: " + email + "." + "\n\nTo confirm this change please use link below:\n\n" + link + "\n\n" + "Message is automatically generated." + "\n----------------------------------------------------------------" + "\nPerun - Identity & Access Management System";
message.setText(text);
mailSender.send(message);
} catch (UnsupportedEncodingException ex) {
throw new InternalErrorException("Unable to encode validation URL for mail change.", ex);
} catch (MalformedURLException ex) {
throw new InternalErrorException("Not valid URL of running Perun instance.", ex);
}
}
use of org.springframework.mail.SimpleMailMessage in project Internet-Software-Architectures by zivko11.
the class Mailing method sendBidAcceptedNotification.
public void sendBidAcceptedNotification(String mail, String propsName) {
String subject = "Your bid is accepted!";
String link = "localhost:8080/cinema-theatre/fanzone.html?propsid=";
String message = "Congratulations! Your bid for " + propsName + " is accepted. You can see props status here: ";
SimpleMailMessage email = new SimpleMailMessage();
email.setTo(mail);
email.setSubject(subject);
email.setText(message + link);
mailSender.send(email);
}
use of org.springframework.mail.SimpleMailMessage in project Internet-Software-Architectures by zivko11.
the class Mailing method sendBidRejectedNotification.
public void sendBidRejectedNotification(String mail, String propsName) {
String subject = "Your bid is rejected!";
String link = "localhost:8080/cinema-theatre/fanzone.html?propsid=";
String message = "Unfortunately, your bid for " + propsName + " is rejected. You can see props status here: ";
SimpleMailMessage email = new SimpleMailMessage();
email.setTo(mail);
email.setSubject(subject);
email.setText(message + link);
mailSender.send(email);
}
Aggregations