Skip to content

Commit

Permalink
bug fix: fix opendkim port on email settings reset; ref: https://app.…
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jan 22, 2024
1 parent 8e0ee86 commit d115168
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions plogical/mailUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,27 +356,39 @@ def setupDKIM(virtualHostName):
keyTable = "/etc/opendkim/KeyTable"
configToWrite = "default._domainkey." + actualDomain + " " + actualDomain + ":default:/etc/opendkim/keys/" + virtualHostName + "/default.private\n"

writeToFile = open(keyTable, 'a')
writeToFile.write(configToWrite)
writeToFile.close()
data = open(keyTable, 'r').read()

if data.find("default._domainkey." + actualDomain) == -1:

writeToFile = open(keyTable, 'a')
writeToFile.write(configToWrite)
writeToFile.close()

## Edit signing table

signingTable = "/etc/opendkim/SigningTable"
configToWrite = "*@" + actualDomain + " default._domainkey." + actualDomain + "\n"

writeToFile = open(signingTable, 'a')
writeToFile.write(configToWrite)
writeToFile.close()
data = open(signingTable, 'r').read()

if data.find("default._domainkey." + actualDomain) == -1:

writeToFile = open(signingTable, 'a')
writeToFile.write(configToWrite)
writeToFile.close()

## Trusted hosts

trustedHosts = "/etc/opendkim/TrustedHosts"
configToWrite = actualDomain + "\n"

writeToFile = open(trustedHosts, 'a')
writeToFile.write(configToWrite)
writeToFile.close()
data = open(trustedHosts, 'r').read()

if data.find(actualDomain) == -1:

writeToFile = open(trustedHosts, 'a')
writeToFile.write(configToWrite)
writeToFile.close()

## Restart Postfix and OpenDKIM

Expand Down Expand Up @@ -2149,6 +2161,14 @@ def installOpenDKIMNew(self):

return 1

def SetupDKIMFromResetMail(self):

for website in Websites.objects.all():
mailUtilities.setupDKIM(website.domain)

for website in ChildDomains.objects.all():
mailUtilities.setupDKIM(website.domain)

def ResetEmailConfigurations(self):
try:
### Check if remote or local mysql
Expand Down Expand Up @@ -2221,6 +2241,8 @@ def ResetEmailConfigurations(self):
'configureOpenDKIM failed. [404].')
return 0

self.SetupDKIMFromResetMail()

if self.MailSSL:
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
'Setting up Mail Server SSL if any..,75')
Expand Down

0 comments on commit d115168

Please sign in to comment.