mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 16:26:12 +01:00
Update to add email forwarding pipe support
This commit is contained in:
51
mailServer/mailserverManager.py
Executable file → Normal file
51
mailServer/mailserverManager.py
Executable file → Normal file
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/local/CyberCP/bin/python2
|
#!/usr/local/CyberCP/bin/python2
|
||||||
|
# coding=utf-8
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
import django
|
import django
|
||||||
@@ -352,8 +353,26 @@ class MailServerManager:
|
|||||||
for items in Pipeprograms.objects.filter(destination=destination, source=source):
|
for items in Pipeprograms.objects.filter(destination=destination, source=source):
|
||||||
items.delete()
|
items.delete()
|
||||||
|
|
||||||
### Michael Ramsey
|
## Delete Email PIPE
|
||||||
## Treat your path deletion code here.
|
sourceusername = source.split("@")[0]
|
||||||
|
virtualalias = '%s %salias' % (source, sourceusername)
|
||||||
|
pipealias = '%salias: "|%s"' % (sourceusername, destination)
|
||||||
|
command = "sed -i 's/^" + source + ".*//g' /etc/postfix/virtual"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
command = "sed -i 's/^" + sourceusername + ".*//g' /etc/aliases"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
#### Restarting Postfix and newalias
|
||||||
|
|
||||||
|
command = "postmap /etc/postfix/virtual"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
command = "systemctl restart postfix"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
##
|
||||||
|
|
||||||
|
command = "newaliases"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
data_ret = {'status': 1, 'deleteForwardingStatus': 1, 'error_message': "None",
|
data_ret = {'status': 1, 'deleteForwardingStatus': 1, 'error_message': "None",
|
||||||
'successMessage': 'Successfully deleted!'}
|
'successMessage': 'Successfully deleted!'}
|
||||||
@@ -387,7 +406,7 @@ class MailServerManager:
|
|||||||
|
|
||||||
if Forwardings.objects.filter(source=source, destination=destination).count() > 0:
|
if Forwardings.objects.filter(source=source, destination=destination).count() > 0:
|
||||||
data_ret = {'status': 0, 'createStatus': 0,
|
data_ret = {'status': 0, 'createStatus': 0,
|
||||||
'error_message': "You have already forwared to this destination."}
|
'error_message': "You have already forwarded to this destination."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -402,8 +421,29 @@ class MailServerManager:
|
|||||||
forwarding = Pipeprograms(source=source, destination=destination)
|
forwarding = Pipeprograms(source=source, destination=destination)
|
||||||
forwarding.save()
|
forwarding.save()
|
||||||
|
|
||||||
### Michael Ramsey
|
## Create Email PIPE
|
||||||
## Treat your path creation code here.
|
## example@domain.com examplealias
|
||||||
|
sourceusername = source.split("@")[0]
|
||||||
|
virtualalias = '%s %salias' % (source, sourceusername)
|
||||||
|
command = "echo '" + virtualalias + "' >> /etc/postfix/virtual"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
## examplealias: "|/usr/bin/php -q /home/domain.com/public_html/ticket/api/pipe.php"
|
||||||
|
pipealias = '%salias: "|%s"' % (sourceusername, destination)
|
||||||
|
command = "echo '" + pipealias + "' >> /etc/aliases"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
#### Restarting Postfix and newalias
|
||||||
|
|
||||||
|
command = "postmap /etc/postfix/virtual"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
command = "systemctl restart postfix"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
##
|
||||||
|
|
||||||
|
command = "newaliases"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
data_ret = {'status': 1, 'createStatus': 1, 'error_message': "None", 'successMessage': 'Successfully Created!'}
|
data_ret = {'status': 1, 'createStatus': 1, 'error_message': "None", 'successMessage': 'Successfully Created!'}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
@@ -724,3 +764,4 @@ class MailServerManager:
|
|||||||
final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)}
|
final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user