diff --git a/config.go b/config.go index b6bf684..d7335bd 100644 --- a/config.go +++ b/config.go @@ -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!") + } } diff --git a/main.go b/main.go index 0024c1f..de436c8 100644 --- a/main.go +++ b/main.go @@ -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 diff --git a/smtprelay.ini b/smtprelay.ini index 50d2c93..c1e90e8 100644 --- a/smtprelay.ini +++ b/smtprelay.ini @@ -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