1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-14 10:53:30 +02:00

Add method to create an alias

This commit is contained in:
Stefan Auditor 2016-12-14 09:40:49 +01:00
parent 2c3c52a2ec
commit f043e50983

View File

@ -51,5 +51,22 @@ def user(localpart, domain_name, password):
db.session.add(user)
db.session.commit()
@manager.command
def alias(localpart, domain_name, destination):
""" Create an alias
"""
domain = models.Domain.query.get(domain_name)
if not domain:
domain = models.Domain(name=domain_name)
db.session.add(domain)
alias = models.Alias(
localpart=localpart,
domain=domain,
destination=destination.split(','),
email="%s@%s" % (localpart, domain_name)
)
db.session.add(alias)
db.session.commit()
if __name__ == "__main__":
manager.run()