
util.MailUtil Maven / Gradle / Ivy
The newest version!
package util;
/**
* Mail-Funktionalität
*
* @author Benedikt Höft, 17.02.2016
*/
public class MailUtil
{
private MailUtil()
{
}
/**
* Sendet eine Email wegen einer Passwort-Zurücksetzung (entweder Neu-Anlegung oder PW-Rest)
*
* @param pUser der betroffene User-Name
* @param pPassword das neue Passwort
* @param pNewUser true wenn ein neuer User angelegt wurde
*/
public static void resetPassword(String pUser, String pPassword, boolean pNewUser)
{
/*AdminUser user = DBMongoClient.getInstance().findAdmin(pUser);
if (pNewUser)
_sendMail(pUser, user.getEmail(), StringBundle.getNewPasswordSubject(), StringBundle.getNewPasswordBody(pUser, pPassword));
else
_sendMail(pUser, user.getEmail(), StringBundle.getResetPasswordSubject(), StringBundle.getResetPasswordBody(pPassword));*/
}
/**
* Sendet eine Email an einen bestimmten Admin, um ihn vor einem niedrigen Beacon-Batterie-Status zu warnen
*
* @param pUser das betroffene Beacon-Mapping
* @param pMsgBody die ID des kritischen Beacons
* @param pMsgSubject der Batteries-Status
*/
private static void _sendMail(String pUser, String pMsgSubject, String pMsgBody)
{
//_sendMail(pUser, pUser + Config.getEmailDomain(), pMsgSubject, pMsgBody);
}
/**
* Sendet eine Email an einen bestimmten Admin, um ihn vor einem niedrigen Beacon-Batterie-Status zu warnen
*
* @param pUser das betroffene Beacon-Mapping
* @param pEmail die ID des kritischen Beacons
* @param pMsgBody der Batteries-Status
* @param pMsgSubject der Batteries-Status
*/
private static void _sendMail(String pUser, String pEmail, String pMsgSubject, String pMsgBody)
{
/*Properties props = System.getProperties();
props.put("mail.transport.protocol", Config.getTransportProtocol());
props.put("mail.smtp.host", Config.getSmtpHost());
props.put("mail.smtp.port", Config.getSmtpPort());
props.put("mail.smtp.starttls.enable", Config.getSmtpStarttls());
props.put("mail.smtp.ssl.trust", Config.getSmtpSslTrust());
props.put("mail.smtp.user", Config.getSystemEmailUser());
props.put("mail.smtp.password", Config.getSystemEmailPassword());
props.put("mail.smtp.auth", Config.getSmtpAuth());
Session session = Session.getDefaultInstance(props, new _Auth());
try
{
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(Config.getSystemEmail(), Config.getSystemEmailAbbreviation()));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(pEmail, pUser));
msg.setSubject(pMsgSubject);
msg.setText(pMsgBody);
Transport.send(msg);
}
catch (MessagingException | UnsupportedEncodingException e)
{
Log.error("Unexpected error while sending mail");
throw new RuntimeException(e);
}*/
}
/*private static class _Auth extends javax.mail.Authenticator
{
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(Config.getSystemEmailUser(), Config.getSystemEmailPassword());
}
}*/
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy