<commit_before>package be.cegeka.batchers.taxcalculator.application.domain.email;

import org.apache.commons.mail.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.util.ByteArrayDataSource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import static java.util.stream.Collectors.toSet;
import static org.apache.commons.lang3.StringUtils.isNoneBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;

@Service
public class EmailSender {
    private static final Logger logger = LoggerFactory.getLogger(EmailSender.class);
    @Value("${smtp_use_ssl}")
    private boolean smtpUseSsl;
    @Value("${smtp_port:465}")
    private int smtpPort;
    @Value("${smtp_server}")
    private String smtpServer;
    @Value("${smtp_user_name}")
    private String smtpUserName;
    @Value("${smtp_user_password}")
    private String smtpPassword;

    public void send(EmailTO emailTO) {
        try {
            Email email = new EmailMapper().mapFromEmailTO(emailTO);
            email.setSSLOnConnect(smtpUseSsl);
            email.setSmtpPort(smtpPort);
            email.setHostName(smtpServer);
            if(isNoneBlank(smtpUserName, smtpPassword)) {
                email.setAuthenticator(new DefaultAuthenticator(smtpUserName, smtpPassword));
            }
<commit_msg>[Radu,Ronald] S14: added email sending and testing<commit_after>package be.cegeka.batchers.taxcalculator.application.domain.email;

import org.apache.commons.mail.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.util.ByteArrayDataSource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import static java.util.stream.Collectors.toSet;
import static org.apache.commons.lang3.StringUtils.isNoneBlank;

@Service
public class EmailSender {
    private static final Logger logger = LoggerFactory.getLogger(EmailSender.class);
    @Value("${smtp_use_ssl:true}")
    private boolean smtpUseSsl;
    @Value("${smtp_port:465}")
    private int smtpPort;
    @Value("${smtp_server}")
    private String smtpServer;
    @Value("${smtp_user_name}")
    private String smtpUserName;
    @Value("${smtp_user_password}")
    private String smtpPassword;

    public void send(EmailTO emailTO) {
        try {
            Email email = new EmailMapper().mapFromEmailTO(emailTO);
            email.setSSLOnConnect(smtpUseSsl);
            email.setSmtpPort(smtpPort);
            email.setHostName(smtpServer);
            if (isNoneBlank(smtpUserName, smtpPassword)) {
                email.setAuthenticator(new DefaultAuthenticator(smtpUserName, smtpPassword));
            }

{'fraction_non_alphanumeric': 0.10548387096774194, 'fraction_numerical': 0.004838709677419355, 'mean_word_length': 4.203020134228188, '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': '3879355', 'n_tokens_mistral': 971, 'n_tokens_neox': 943, 'n_words': 168}