Merge pull request #16 from decke/discard

Discard mail if remote_host is not set
This commit is contained in:
Bernhard Fröhlich
2021-03-13 19:06:08 +01:00
committed by GitHub
3 changed files with 13 additions and 2 deletions

View File

@@ -25,7 +25,7 @@ var (
allowedSender = flag.String("allowed_sender", "", "Regular expression for valid FROM EMail addresses")
allowedRecipients = flag.String("allowed_recipients", "", "Regular expression for valid TO EMail addresses")
allowedUsers = flag.String("allowed_users", "", "Path to file with valid users/passwords")
remoteHost = flag.String("remote_host", "smtp.gmail.com:587", "Outgoing SMTP server")
remoteHost = flag.String("remote_host", "", "Outgoing SMTP server")
remoteUser = flag.String("remote_user", "", "Username for authentication on outgoing SMTP server")
remotePass = flag.String("remote_pass", "", "Password for authentication on outgoing SMTP server")
remoteAuth = flag.String("remote_auth", "plain", "Auth method on outgoing SMTP server (plain, login)")
@@ -38,4 +38,8 @@ func ConfigLoad() {
// Set up logging as soon as possible
setupLogger()
if (*remoteHost == "") {
log.Warn("remote_host not set; mail will not be forwarded!")
}
}

View File

@@ -180,6 +180,12 @@ func mailHandler(peer smtpd.Peer, env smtpd.Envelope) error {
"host": *remoteHost,
"uuid": generateUUID(),
})
if (*remoteHost == "") {
logger.Warning("remote_host not set; discarding mail")
return nil
}
logger.Info("delivering mail from peer using smarthost")
var auth smtp.Auth

View File

@@ -53,7 +53,8 @@
; E.g. "app@example.com,@appsrv.example.com"
;allowed_users =
; Relay all mails to this SMTP server
; Relay all mails to this SMTP server.
; If not set, mails are discarded.
; GMail
;remote_host = smtp.gmail.com:587