<commit_before>package eu.erbs.financehacks;

import java.io.IOException;
import java.util.Properties;
import java.util.logging.Logger;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import static eu.erbs.financehacks.AccountRobot.loadProperties;

public class EmailNotifier {
	
	static Properties mailServerProperties;
	static Session getMailSession;
	static MimeMessage generateMailMessage;
	
	final static String MAIL_PROPERTIES_PATH = "mail.properties";
	final static String MAIL_HOST = "MAIL_HOST";
	final static String MAIL_USER = "MAIL_USER";
	final static String MAIL_PASSWORD = "<PASSWORD>";

	final static String SUBJECT_TAG = "[FINANCE HACKS]";

	
	private static final Logger log = Logger.getLogger(EmailNotifier.class.getName());
	public EmailNotifier() throws IOException{
		log.fine("Setup Mail Server Properties..");
		mailServerProperties = System.getProperties();
		mailServerProperties.put("mail.smtp.port", "587");
		mailServerProperties.put("mail.smtp.auth", "true");
		mailServerProperties.put("mail.smtp.starttls.enable", "true");
		
		loadProperties(MAIL_PROPERTIES_PATH, mailServerProperties);

		log.fine("Mail Server Properties have been setup successfully..");
	}

	public void sendEmail(String recipient, String subject, String emailBody) throws MessagingException{


		log.fine("Get Mail Session..");
		getMailSession = Session.getDefaultInstance(mailServerProperties, null);
		generateMailMessage = new MimeMessage(getMailSession);
		generateMailMessage.setFrom(new InternetAddress(mailServerProperties.getProperty(MAIL_USER)));
		if(recipient.contains(",")){
			for(String to : recipient.split(",")){
				generateMailMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(to));			
			}
		}
		else{
			generateMailMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
		}
		generateMailMessage.setSubject(SUBJECT_TAG + " " + subject);
		generateMailMessage.setContent(getPoliteMail(emailBody), "text/html");
		log.info("Mail Session has been created successfully..");
<commit_msg>Bug fix<commit_after>package eu.erbs.financehacks;

import java.io.IOException;
import java.util.Properties;
import java.util.logging.Logger;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import static eu.erbs.financehacks.AccountRobot.loadProperties;

public class EmailNotifier {
	
	static Properties mailServerProperties;
	static Session getMailSession;
	static MimeMessage generateMailMessage;
	
	final static String MAIL_PROPERTIES_PATH = "mail.properties";
	final static String MAIL_HOST = "MAIL_HOST";
	final static String MAIL_USER = "MAIL_USER";
	final static String MAIL_PASSWORD = "<PASSWORD>";

	final static String SUBJECT_TAG = "[FINANCE HACKS]";

	
	private static final Logger log = Logger.getLogger(EmailNotifier.class.getName());
	public EmailNotifier() throws IOException{
		log.fine("Setup Mail Server Properties..");
		mailServerProperties = System.getProperties();
		mailServerProperties.put("mail.smtp.port", "587");
		mailServerProperties.put("mail.smtp.auth", "true");
		mailServerProperties.put("mail.smtp.starttls.enable", "true");
		
		loadProperties(MAIL_PROPERTIES_PATH, mailServerProperties);

		log.fine("Mail Server Properties have been setup successfully..");
	}

	public void sendEmail(String recipient, String subject, String emailBody) throws MessagingException{


		log.fine("Get Mail Session..");
		getMailSession = Session.getDefaultInstance(mailServerProperties, null);
		generateMailMessage = new MimeMessage(getMailSession);
		generateMailMessage.setFrom(new InternetAddress(mailServerProperties.getProperty(MAIL_USER)));
		if(recipient.contains(",")){
			for(String to : recipient.split(",")){
				generateMailMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(to));			
			}
		}
		else{
			generateMailMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
		}
		generateMailMessage.setSubject(SUBJECT_TAG + " " + subject);
		generateMailMessage.setContent(getPoliteMail(emailBody), "text/html");
		log.info("Mail Session has been created successfully..");

{'fraction_non_alphanumeric': 0.10924750679963735, 'fraction_numerical': 0.0013599274705349048, 'mean_word_length': 6.2344262295081965, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6032693', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1257, 'n_words': 269}