<commit_before>package com.jolocom.webidproxy.email;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.Properties;

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 org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;

import com.jolocom.webidproxy.users.User;

public abstract class Email {

	private static final Log log = LogFactory.getLog(Email.class);

	private User user;
	private String host;
	private String to;
	private String from;
	private String subject;
	private String template;

	public Email(User user, String resource) {

		this.user = user;
		this.host = "localhost";
		this.to = user.getEmail();

		this.readResource(resource);
	}

	public void readResource(String resource) {

		BufferedReader reader = new BufferedReader(new InputStreamReader(ForgotPasswordEmail.class.getResourceAsStream(resource), StandardCharsets.UTF_8));
		StringBuffer template = new StringBuffer();

		try {

			this.setFrom(reader.readLine());
			this.setSubject(reader.readLine());

			String line;
			while (((line = reader.readLine()) != null)) template.append(line);
			this.setTemplate(template.toString());
			reader.close();
		} catch (IOException ex) {

			throw new RuntimeException(ex.getMessage(), ex);
		}
	}

	public void send() throws MessagingException {

		// set host

		Properties properties = System.getProperties();
		properties.setProperty("mail.smtp.host", this.getHost());

		// start a session

		Session session = Session.getDefaultInstance(properties);

		// render message text from template

		VelocityEngine velocity = new VelocityEngine();
		velocity.init();
		VelocityContext context = new VelocityContext();
		context.put("user", this.getUser());
		context.put("newline", "\n");
		StringReader reader = new StringReader(this.getTemplate());
		StringWriter writer = new StringWriter();
		velocity.evaluate(context, writer, this.getClass().getSimpleName(), reader);

		// create message

		MimeMessage message = new MimeMessage(session);
		message.setFrom(new InternetAddress(this.getFrom()));
		message.addRecipient(Message.RecipientType.TO, new InternetAddress(this.getTo()));
		message.setSubject(this.getSubject());
		message.setText(writer.toString());

		try {
			message.writeTo(System.out);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		// send message

		Transport.send(message);
	}

	public User getUser() {

		return this.user;
	}

	public void setUser(User user) {

		this.user = user;
	}

	public String getHost() {

		return this.host;
	}
<commit_msg>don't log email to stdout<commit_after>package com.jolocom.webidproxy.email;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.Properties;

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 org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;

import com.jolocom.webidproxy.users.User;

public abstract class Email {

	private static final Log log = LogFactory.getLog(Email.class);

	private User user;
	private String host;
	private String to;
	private String from;
	private String subject;
	private String template;

	public Email(User user, String resource) {

		this.user = user;
		this.host = "localhost";
		this.to = user.getEmail();

		this.readResource(resource);
	}

	public void readResource(String resource) {

		BufferedReader reader = new BufferedReader(new InputStreamReader(ForgotPasswordEmail.class.getResourceAsStream(resource), StandardCharsets.UTF_8));
		StringBuffer template = new StringBuffer();

		try {

			this.setFrom(reader.readLine());
			this.setSubject(reader.readLine());

			String line;
			while (((line = reader.readLine()) != null)) template.append(line);
			this.setTemplate(template.toString());
			reader.close();
		} catch (IOException ex) {

			throw new RuntimeException(ex.getMessage(), ex);
		}
	}

	public void send() throws MessagingException {

		// set host

		Properties properties = System.getProperties();
		properties.setProperty("mail.smtp.host", this.getHost());

		// start a session

		Session session = Session.getDefaultInstance(properties);

		// render message text from template

		VelocityEngine velocity = new VelocityEngine();
		velocity.init();
		VelocityContext context = new VelocityContext();
		context.put("user", this.getUser());
		context.put("newline", "\n");
		StringReader reader = new StringReader(this.getTemplate());
		StringWriter writer = new StringWriter();
		velocity.evaluate(context, writer, this.getClass().getSimpleName(), reader);

		// create message

		MimeMessage message = new MimeMessage(session);
		message.setFrom(new InternetAddress(this.getFrom()));
		message.addRecipient(Message.RecipientType.TO, new InternetAddress(this.getTo()));
		message.setSubject(this.getSubject());
		message.setText(writer.toString());

		// send message

		Transport.send(message);
	}

	public User getUser() {

		return this.user;
	}

	public void setUser(User user) {

		this.user = user;
	}

	public String getHost() {

		return this.host;
	}

{'fraction_non_alphanumeric': 0.11894574704774945, 'fraction_numerical': 0.0003422899195618689, 'mean_word_length': 4.820717131474104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6956168', 'n_tokens_mistral': 1868, 'n_tokens_neox': 1684, 'n_words': 396}