mirror of
https://github.com/decke/smtprelay.git
synced 2025-12-25 16:02:31 -07:00
Merge pull request #16 from decke/discard
Discard mail if remote_host is not set
This commit is contained in:
@@ -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!")
|
||||
}
|
||||
}
|
||||
|
||||
6
main.go
6
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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user