refactor a bit

This commit is contained in:
Aine
2023-05-10 22:43:52 +03:00
parent 81c6d5abf1
commit 9bcc2d462f
4 changed files with 26 additions and 32 deletions

View File

@@ -26,10 +26,10 @@ var (
)
type mailServer struct {
bot matrixbot
log *logger.Logger
domains []string
mailSender MailSender
bot matrixbot
log *logger.Logger
domains []string
sender MailSender
}
// Login used for outgoing mail submissions only (when you use postmoogle as smtp server in your scripts)
@@ -54,7 +54,7 @@ func (m *mailServer) Login(state *smtp.ConnectionState, username, password strin
return &outgoingSession{
ctx: sentry.SetHubOnContext(context.Background(), sentry.CurrentHub().Clone()),
sendmail: m.SendEmail,
sendmail: m.sender.Send,
privkey: m.bot.GetDKIMprivkey(),
from: username,
log: m.log,
@@ -87,11 +87,6 @@ func (m *mailServer) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session,
}, nil
}
// SendEmail to external mail server
func (m *mailServer) SendEmail(from, to, data string) error {
return m.mailSender.Send(from, to, data)
}
// ReceiveEmail - incoming mail into matrix room
func (m *mailServer) ReceiveEmail(ctx context.Context, eml *email.Email) error {
return m.bot.IncomingEmail(ctx, eml)