mirror of
https://github.com/decke/smtprelay.git
synced 2025-12-25 18:52:29 -07:00
Discard mail if remote_host is not set
This is useful for test environments.
This commit is contained in:
@@ -25,7 +25,7 @@ var (
|
|||||||
allowedSender = flag.String("allowed_sender", "", "Regular expression for valid FROM EMail addresses")
|
allowedSender = flag.String("allowed_sender", "", "Regular expression for valid FROM EMail addresses")
|
||||||
allowedRecipients = flag.String("allowed_recipients", "", "Regular expression for valid TO 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")
|
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")
|
remoteUser = flag.String("remote_user", "", "Username for authentication on outgoing SMTP server")
|
||||||
remotePass = flag.String("remote_pass", "", "Password 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)")
|
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
|
// Set up logging as soon as possible
|
||||||
setupLogger()
|
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,
|
"host": *remoteHost,
|
||||||
"uuid": generateUUID(),
|
"uuid": generateUUID(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (*remoteHost == "") {
|
||||||
|
logger.Warning("remote_host not set; discarding mail")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
logger.Info("delivering mail from peer using smarthost")
|
logger.Info("delivering mail from peer using smarthost")
|
||||||
|
|
||||||
var auth smtp.Auth
|
var auth smtp.Auth
|
||||||
|
|||||||
@@ -53,7 +53,8 @@
|
|||||||
; E.g. "app@example.com,@appsrv.example.com"
|
; E.g. "app@example.com,@appsrv.example.com"
|
||||||
;allowed_users =
|
;allowed_users =
|
||||||
|
|
||||||
; Relay all mails to this SMTP server
|
; Relay all mails to this SMTP server.
|
||||||
|
; If not set, mails are discarded.
|
||||||
|
|
||||||
; GMail
|
; GMail
|
||||||
;remote_host = smtp.gmail.com:587
|
;remote_host = smtp.gmail.com:587
|
||||||
|
|||||||
Reference in New Issue
Block a user