<commit_before>package mailer

import (
	"bytes"
	"crypto/tls"
	"fmt"
	"mime/quotedprintable"
	"net"
	net_mail "net/mail"
	"net/smtp"

	"time"

	"github.com/bborbe/log"
)

var logger = log.DefaultLogger

type Config interface {
	SmtpUser() string
	SmtpPassword() string
	SmtpHost() string
	SmtpPort() int
	Tls() bool
	TlsSkipVerify() bool
	Timeout() time.Duration
}

type Message interface {
	Sender() string
	Recipient() string
	Content() string
	Subject() string
}

type mailer struct {
	config Config
}

type Mailer interface {
	Send(message Message) error
}

func New(config Config) *mailer {
	m := new(mailer)
	m.config = config
	return m
}

func (s *mailer) Send(message Message) error {
	logger.Debugf("sendMail to %s", message.Recipient())

	servername := fmt.Sprintf("%s:%d", s.config.SmtpHost(), s.config.SmtpPort())
	logger.Debugf("connect to smtp-server to %s", servername)

	from := net_mail.Address{"", message.Sender()}
	to := net_mail.Address{"", message.Recipient()}

	headers := make(map[string]string)
	headers["From"] = from.String()
	headers["To"] = to.String()
	headers["Subject"] = "=?UTF-8?Q?" + QuoteString(message.Subject()) + "?="
	headers["Content-Type"] = `text/plain; charset="utf-8"`
	headers["Content-Transfer-Encoding"] = `quoted-printable`

	content := ""
	for k, v := range headers {
		content += fmt.Sprintf("%s: %s\r\n", k, v)<commit_msg>add keys<commit_after>package mailer

import (
	"bytes"
	"crypto/tls"
	"fmt"
	"mime/quotedprintable"
	"net"
	net_mail "net/mail"
	"net/smtp"

	"time"

	"github.com/bborbe/log"
)

var logger = log.DefaultLogger

type Config interface {
	SmtpUser() string
	SmtpPassword() string
	SmtpHost() string
	SmtpPort() int
	Tls() bool
	TlsSkipVerify() bool
	Timeout() time.Duration
}

type Message interface {
	Sender() string
	Recipient() string
	Content() string
	Subject() string
}

type mailer struct {
	config Config
}

type Mailer interface {
	Send(message Message) error
}

func New(config Config) *mailer {
	m := new(mailer)
	m.config = config
	return m
}

func (s *mailer) Send(message Message) error {
	logger.Debugf("sendMail to %s", message.Recipient())

	servername := fmt.Sprintf("%s:%d", s.config.SmtpHost(), s.config.SmtpPort())
	logger.Debugf("connect to smtp-server to %s", servername)

	from := net_mail.Address{
		Name:    "",
		Address: message.Sender(),
	}
	to := net_mail.Address{
		Name:    "",
		Address: message.Recipient(),
	}

	headers := make(map[string]string)
	headers["From"] = from.String()
	headers["To"] = to.String()
	headers["Subject"] = "=?UTF-8?Q?" + QuoteString(message.Subject()) + "?="
	headers["Content-Type"] = `text/plain; charset="utf-8"`
	headers["Content-Transfer-Encoding"] = `quoted-printable`

	content := ""
	for k, v := range headers {
		content += fmt.Sprintf("%s: %s\r\n", k, v)
{'fraction_non_alphanumeric': 0.16875223453700394, 'fraction_numerical': 0.0014301036825169824, 'mean_word_length': 4.573705179282869, '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': '5542532', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1032, 'n_words': 236}