Compare commits
2 Commits
f1bbd0c274
...
93ee76e130
| Author | SHA1 | Date | |
|---|---|---|---|
| 93ee76e130 | |||
| 5c8238bed3 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
data/*
|
||||
*.yml
|
||||
*.conf
|
||||
*.swp
|
||||
|
||||
13
ovh-mail.py
13
ovh-mail.py
@ -15,7 +15,7 @@ def writeRedirectionsToFile(client,domain):
|
||||
file.write(redirection['from']+','+redirection['to']+','+redirection['id']+'\n')
|
||||
file.close()
|
||||
|
||||
def checkRedirExists(client,domain, fr,to):
|
||||
def checkRedirExists(client,domain,fr,to):
|
||||
mailbox = client.get('/email/domain/' + domain + '/redirection')
|
||||
for id in mailbox:
|
||||
redirection = client.get('/email/domain/' + domain +'/redirection/'+str(id))
|
||||
@ -33,6 +33,15 @@ def addRedirection(client,domain,fr,to):
|
||||
print(json.dumps(result,indent=4))
|
||||
return 0
|
||||
|
||||
def delRedirection(client,domain,fr,to):
|
||||
id_redir = checkRedirExists(client,domain,fr,to)
|
||||
if not id_redir:
|
||||
return False
|
||||
else:
|
||||
result = client.delete('/email/domain/'+ domain +'/redirection/' + str(id_redir))
|
||||
print(json.dumps(result,indent=4))
|
||||
return 0
|
||||
|
||||
parser = argparse.ArgumentParser(description='Process arguments')
|
||||
parser.add_argument('method', metavar='method', type=str, help='Function to use')
|
||||
parser.add_argument('domain', metavar='domain', type=str, help='domain')
|
||||
@ -52,3 +61,5 @@ if (args.method == "write"):
|
||||
elif (args.method == "add"):
|
||||
if not (checkRedirExists(client,args.domain,args.fr,args.to)):
|
||||
addRedirection(client,args.domain,args.fr,args.to)
|
||||
elif (args.method == "del"):
|
||||
status = delRedirection(client,args.domain,args.fr,args.to)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user