Skip to content

BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr

feat: create empty sender relay maps and SASL password files if they do not exist

lotk3a585dff6fe5
diff --git a/core/internal/service/relay/config_sync.go b/core/internal/service/relay/config_sync.go
index ba47ab4a..1cc01b0d 100644
--- a/core/internal/service/relay/config_sync.go
+++ b/core/internal/service/relay/config_sync.go
@@ -600,8 +600,30 @@ func reloadPostfixConfigs(ctx context.Context) error {
return gerror.Wrap(err, "Failed to connect to Docker service")
}
defer dk.Close()
+
+ senderRelayMapsPrimaryPath := path.Join(postfixConfigDir, senderRelayMapsPrimaryFile)
+ saslPasswdPrimaryPath := path.Join(postfixConfigDir, saslPasswdPrimaryFile)
+
+ if !gfile.Exists(senderRelayMapsPrimaryPath) {
+ if err := gfile.PutContents(senderRelayMapsPrimaryPath, ""); err != nil {
+ g.Log().Errorf(ctx, "Failed to create %s: %v", senderRelayMapsPrimaryPath, err)
+ } else {
+ g.Log().Infof(ctx, "Created empty sender_relay_maps_primary file")
+ }
+ }
+
+ if !gfile.Exists(saslPasswdPrimaryPath) {
+ if err := gfile.PutContents(saslPasswdPrimaryPath, ""); err != nil {
+ g.Log().Errorf(ctx, "Failed to create %s: %v", saslPasswdPrimaryPath, err)
+ } else {
+ g.Log().Infof(ctx, "Created empty sasl_passwd_primary file")
+ }
+ }
+
// List of commands to run
cmdsToRun := [][]string{
+ {"postmap", "/etc/postfix/conf/sender_relay_maps_primary"},
+ {"postmap", "/etc/postfix/conf/sasl_passwd_primary"},
{"postmap", "/etc/postfix/conf/sasl_passwd"},
{"postfix", "reload"},
}