1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-07-17 01:32:33 +02:00

Minor code changes

This commit is contained in:
Ralph Slooten
2023-05-05 17:21:43 +12:00
parent e77d0a750d
commit b4a971f552
3 changed files with 11 additions and 9 deletions

View File

@ -2,11 +2,13 @@ package smtpd
import ( import (
"crypto/tls" "crypto/tls"
"errors"
"fmt" "fmt"
"github.com/axllent/mailpit/config"
"github.com/axllent/mailpit/utils/logger"
"net/mail" "net/mail"
"net/smtp" "net/smtp"
"github.com/axllent/mailpit/config"
"github.com/axllent/mailpit/utils/logger"
) )
func allowedRecipients(to []string) []string { func allowedRecipients(to []string) []string {
@ -39,7 +41,7 @@ func Send(from string, to []string, msg []byte) error {
recipients := allowedRecipients(to) recipients := allowedRecipients(to)
if len(recipients) == 0 { if len(recipients) == 0 {
return nil return errors.New("no valid recipients")
} }
addr := fmt.Sprintf("%s:%d", config.SMTPRelayConfig.Host, config.SMTPRelayConfig.Port) addr := fmt.Sprintf("%s:%d", config.SMTPRelayConfig.Host, config.SMTPRelayConfig.Port)

View File

@ -42,7 +42,7 @@ func mailHandler(origin net.Addr, from string, to []string, data []byte) error {
// if enabled, this will route the email 1:1 through to the preconfigured smtp server // if enabled, this will route the email 1:1 through to the preconfigured smtp server
if config.SMTPRelayAllIncoming { if config.SMTPRelayAllIncoming {
if err := Send(from, to, data); err != nil { if err := Send(from, to, data); err != nil {
logger.Log().Errorf("[smtp] error relaying message: %s", err.Error()) logger.Log().Warnf("[smtp] error relaying message: %s", err.Error())
} else { } else {
logger.Log().Debugf("[smtp] relayed message from %s via %s:%d", from, config.SMTPRelayConfig.Host, config.SMTPRelayConfig.Port) logger.Log().Debugf("[smtp] relayed message from %s via %s:%d", from, config.SMTPRelayConfig.Host, config.SMTPRelayConfig.Port)
} }

View File

@ -83,11 +83,11 @@ export default {
<div class="invalid-feedback">Invalid email address</div> <div class="invalid-feedback">Invalid email address</div>
</div> </div>
</div> </div>
<div class="form-text text-center" v-if="relayConfig.MessageRelay.RecipientAllowlist != ''"> <div class="form-text text-center" v-if="relayConfig.MessageRelay.RecipientAllowlist != ''">
Note: A recipient allowlist has been configured. Any mail address not matching it will be rejected. Note: A recipient allowlist has been configured. Any mail address not matching it will be rejected.
<br class="d-none d-md-inline"> <br class="d-none d-md-inline">
Configured allowlist: <b>{{ relayConfig.MessageRelay.RecipientAllowlist }}</b> Configured allowlist: <b>{{ relayConfig.MessageRelay.RecipientAllowlist }}</b>
</div> </div>
<div class="form-text text-center"> <div class="form-text text-center">
Note: For testing purposes, a unique Message-Id will be generated on send. Note: For testing purposes, a unique Message-Id will be generated on send.
<br class="d-none d-md-inline"> <br class="d-none d-md-inline">