<commit_before>package org.codemonkey.simplejavamail;

import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
import java.util.Properties;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.Address;
import javax.mail.Authenticator;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Part;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;

import org.apache.log4j.Logger;

/**
 * Mailing tool aimed for simplicity, for sending e-mails of any complexity. This includes e-mails with plain text and/or html content,
 * embedded images and separate attachments, SMTP, SMTPS / SSL and SMTP + SSL<br />
 * <br />
 * This mailing tool abstracts the javax.mail API to a higher level easy to use API. For public use, this tool only works with {@link Email}
 * instances. <br />
 * <br />
 * The e-mail message structure is built to work with all e-mail clients and has been tested with many different webclients as well as some
 * mainstream client applications such as MS Outlook or Mozilla Thunderbird.<br />
 * <br />
 * Technically, the resulting email structure is as follows:<br />
 * 
 * <pre>
 * - root
 * 	- related
 * 		- alternative
 * 			- mail text
 * 			- mail html text
 * 		- embedded images
 * 	- attachments
 * </pre>
 * 
 * <br />
 * Usage example:<br />
 * 
 * <pre>
 * Email email = new Email();
 * email.setFromAddress(&quot;lollypop&quot;, &quot;<EMAIL>&quot;);
 * email.addRecipient(&quot;Sugar Cane&quot;, &quot;<EMAIL>&quot;, RecipientType.TO);
 * email.setText(&quot;We should meet up!!&quot;);
 * email.setTextHTML(&quot;&lt;b&gt;We should meet up!&lt;/b&gt;&quot;);
 * email.setSubject(&quot;Hey&quot;);
 * new Mailer(preconfiguredMailSession).sendMail(email);
 * // or:
 * new Mailer(&quot;smtp.someserver.com&quot;, 25, &quot;username&quot;, &quot;password&quot;).sendMail(email);
 * </pre>
 * 
 * @author <NAME>
 * @see MimeEmailMessageWrapper
 * @see Email
 */
public class Mailer {

	private static final Logger logger = Logger.getLogger(Mailer.class);
	
	/**
	 * Encoding used for setting body text, email address, headers, reply-to fields etc. ({@value #CHARACTER_ENCODING}).
	 */
	private static final String CHARACTER_ENCODING = "UTF-8";

	/**
	 * Used to actually send the email. This session can come from being passed in the default constructor, or made by <code>Mailer</code>
	 * directly, when no <code>Session</code> instance was provided.
	 * 
	 * @see #Mailer(Session)
	 * @see #Mailer(String, Integer, String, String, TransportStrategy)
	 */
	private final Session session;

	/**<commit_msg>use SLF4J<commit_after>package org.codemonkey.simplejavamail;

import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
import java.util.Properties;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.Address;
import javax.mail.Authenticator;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Part;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Mailing tool aimed for simplicity, for sending e-mails of any complexity. This includes e-mails with plain text and/or html content,
 * embedded images and separate attachments, SMTP, SMTPS / SSL and SMTP + SSL<br />
 * <br />
 * This mailing tool abstracts the javax.mail API to a higher level easy to use API. For public use, this tool only works with {@link Email}
 * instances. <br />
 * <br />
 * The e-mail message structure is built to work with all e-mail clients and has been tested with many different webclients as well as some
 * mainstream client applications such as MS Outlook or Mozilla Thunderbird.<br />
 * <br />
 * Technically, the resulting email structure is as follows:<br />
 * 
 * <pre>
 * - root
 * 	- related
 * 		- alternative
 * 			- mail text
 * 			- mail html text
 * 		- embedded images
 * 	- attachments
 * </pre>
 * 
 * <br />
 * Usage example:<br />
 * 
 * <pre>
 * Email email = new Email();
 * email.setFromAddress(&quot;lollypop&quot;, &quot;<EMAIL>&quot;);
 * email.addRecipient(&quot;Sugar Cane&quot;, &quot;<EMAIL>&quot;, RecipientType.TO);
 * email.setText(&quot;We should meet up!!&quot;);
 * email.setTextHTML(&quot;&lt;b&gt;We should meet up!&lt;/b&gt;&quot;);
 * email.setSubject(&quot;Hey&quot;);
 * new Mailer(preconfiguredMailSession).sendMail(email);
 * // or:
 * new Mailer(&quot;smtp.someserver.com&quot;, 25, &quot;username&quot;, &quot;password&quot;).sendMail(email);
 * </pre>
 * 
 * @author <NAME>
 * @see MimeEmailMessageWrapper
 * @see Email
 */
public class Mailer {

	private static final Logger logger = LoggerFactory.getLogger(Mailer.class);
	
	/**
	 * Encoding used for setting body text, email address, headers, reply-to fields etc. ({@value #CHARACTER_ENCODING}).
	 */
	private static final String CHARACTER_ENCODING = "UTF-8";

	/**
	 * Used to actually send the email. This session can come from being passed in the default constructor, or made by <code>Mailer</code>
	 * directly, when no <code>Session</code> instance was provided.
	 * 
	 * @see #Mailer(Session)
	 * @see #Mailer(String, Integer, String, String, TransportStrategy)
	 */
	private final Session session;

	/**
{'fraction_non_alphanumeric': 0.12474437627811862, 'fraction_numerical': 0.0017041581458759373, 'mean_word_length': 4.429232192414431, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, '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': '3952007', 'n_tokens_mistral': 1887, 'n_tokens_neox': 1786, 'n_words': 537}