1

Topic: Adding postmaster, webmaster and abuse to new domains?

==== Provide required information to help troubleshoot and get quick answer ====
- Linux/BSD distribution name and version: CentOS 5
- iRedMail version and backend (LDAP/MySQL): MySQL
- Any related log? Log is helpful for troubleshooting.
====

Is there a possible way to automaticly add some default mail accounts or aliases to new domains like postmaster, webmaster and abuse ?
Thanks in advance!
Jens

2

Re: Adding postmaster, webmaster and abuse to new domains?

First of all, you can add them manually.

Back to your request, automate.
Adding new mail domain is handled in file libs/mysql/domain.py, function add().

class Domain:
    ...

    @decorators.require_global_admi
    def add(self, data):
        ...
        # Add domain in database.
        try:
            ...
        except Exception, e:
            ...

If you want to create some mail accounts (users/aliases) automatically, please place your code in block try...except....

For example, create an alias:

        # Add domain in database.
        try:
            self.conn.insert(
                'domain',
                domain=self.domain,
                description=self.cn,
                transport=cfg.general.get('transport', 'dovecot'),
                created=iredutils.sqlNOW,
                active='1',
            )

            self.conn.insert(
                'alias',
                domain=self.domain,
                name='Webmaster',
                address='webmaster@' + self.domain,
                goto='bigjens@domain.ltd',
                active='1',
            )

            web.logger(msg="Create domain: %s." % (self.domain), domain=self.domain, event='create',)
        except Exception, e:
            return (False, str(e))

Will consider making iRedAdmin-Pro handle this as a hook, then what you need to do is just writing down alias name and members in libs/settings.py.

P.S. If you need to modify source code, that means you may need a hook instead of modifying it yourself. Please don't hesitate to let me know your need.

3

Re: Adding postmaster, webmaster and abuse to new domains?

That looks nice! We will give it a try. Thank you so far.