<commit_before>package notifier

import (
	"fmt"
	"net/smtp"
	"strings"

	"github.com/pkg/errors"

	"github.com/stefanprodan/mgob/pkg/config"
)

func sendEmailNotification(subject string, body string, config *config.SMTP) error {

	msg := "From: \"MGOB\" <" + config.From + ">\r\n" +
		"To: " + strings.Join(config.To, ", ") + "\r\n" +
		"Subject: " + subject + "\r\n\r\n" +
		body + "\r\n"

	addr := fmt.Sprintf("%v:%v", config.Server, config.Port)
	auth := smtp.PlainAuth("", config.Username, config.Password, config.Server)

	if err := smtp.SendMail(addr, auth, config.From, config.To, []byte(msg)); err != nil {
		return errors.Wrapf(err, "sending email notification failed")
	}
	return nil
}<commit_msg>disable smtp auth part when username is empty<commit_after>package notifier

import (
	"fmt"
	"net/smtp"
	"strings"

	"github.com/pkg/errors"

	"github.com/stefanprodan/mgob/pkg/config"
)

func sendEmailNotification(subject string, body string, config *config.SMTP) error {

	msg := "From: \"MGOB\" <" + config.From + ">\r\n" +
		"To: " + strings.Join(config.To, ", ") + "\r\n" +
		"Subject: " + subject + "\r\n\r\n" +
		body + "\r\n"

	addr := fmt.Sprintf("%v:%v", config.Server, config.Port)

	// auth is set to nil by default
	// workaround for error given if auth is disabled on the smtp server
	// notifier error: "smtp: server doesn't support AUTH"
	var auth smtp.Auth
	if config.Username != "" {
		auth = smtp.PlainAuth("", config.Username, config.Password, config.Server)
	}

	if err := smtp.SendMail(addr, auth, config.From, config.To, []byte(msg)); err != nil {
		return errors.Wrapf(err, "sending email notification failed")
	}
	return nil
}
{'fraction_non_alphanumeric': 0.1783132530120482, 'fraction_numerical': 0.0, 'mean_word_length': 3.800578034682081, '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': '1508272', 'n_tokens_mistral': 631, 'n_tokens_neox': 604, 'n_words': 148}