2015-02-01 05:22:03 -06:00
|
|
|
# SQL: Add a mail alias account
|
|
|
|
|
|
|
|
[TOC]
|
|
|
|
|
2017-07-08 22:25:23 -05:00
|
|
|
!!! attention
|
2017-07-02 21:02:07 -05:00
|
|
|
|
|
|
|
* This document is applicable to iRedMail-0.9.7 and later releases.
|
|
|
|
* Here's [doc for iRedMail-0.9.6 and earlier releases](./sql.create.mail.alias-20170701.html).
|
|
|
|
|
2015-02-01 05:22:03 -06:00
|
|
|
## Create mail alias account with iRedAdmin-Pro
|
|
|
|
|
|
|
|
With iRedAdmin-Pro, you can easily add mail list account by click menu:
|
2015-08-04 22:07:00 -05:00
|
|
|
`Add -> Mail List` (or `Add -> Alias` for SQL backends) in main
|
2015-08-01 23:20:30 -05:00
|
|
|
navigation bar.
|
2015-02-01 05:22:03 -06:00
|
|
|
|
2017-10-28 00:38:13 -05:00
|
|
|
![](./images/iredadmin/maillist_create.png)
|
2015-02-01 05:22:03 -06:00
|
|
|
|
|
|
|
## Create mail alias account with SQL command line
|
2014-09-22 21:47:49 -05:00
|
|
|
|
2017-07-02 21:02:07 -05:00
|
|
|
To create an mail alias account, you need to add SQL records in 2 sql tables.
|
|
|
|
for example: create a mail alias account `alias@mydomain.com` and forward emails
|
|
|
|
to two addresses `someone@gmail.com` and `someone@test.com`:
|
2014-09-22 21:47:49 -05:00
|
|
|
|
|
|
|
```mysql
|
|
|
|
sql> USE vmail;
|
2017-07-02 21:02:07 -05:00
|
|
|
|
|
|
|
-- Create mail alias account
|
|
|
|
sql> INSERT INTO alias (address, domain, active)
|
|
|
|
VALUES ('alias@mydomain.com', 'mydomain.com', 1);
|
|
|
|
|
|
|
|
-- Forward email to 'someone@gmail.com'
|
|
|
|
sql> INSERT INTO forwardings (address, forwarding,
|
|
|
|
domain, dest_domain,
|
|
|
|
is_list, active)
|
|
|
|
VALUES ('alias@mydomain.com', 'someone@gmail.com',
|
|
|
|
'mydomain.com', 'gmail.com',
|
|
|
|
1, 1);
|
|
|
|
|
|
|
|
-- Forward email to 'someone@test.com'
|
|
|
|
sql> INSERT INTO forwardings (address, forwarding,
|
|
|
|
domain, dest_domain,
|
|
|
|
is_list, active)
|
|
|
|
VALUES ('alias@mydomain.com', 'someone@test.com',
|
|
|
|
'mydomain.com', 'test.com',
|
|
|
|
1, 1);
|
2014-09-22 21:47:49 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
__NOTES__:
|
|
|
|
|
|
|
|
* Please always use lower cases for email addresses.
|
2015-02-20 08:02:03 -06:00
|
|
|
* If destination address is a mail user under domain hosted on localhost,
|
2014-09-22 21:47:49 -05:00
|
|
|
it must exist. Otherwise emails sent to alias account will be bounced after
|
|
|
|
expanded to destination addresses.
|
2015-02-01 05:22:03 -06:00
|
|
|
|
|
|
|
## Access policy
|
|
|
|
|
2017-07-02 21:02:07 -05:00
|
|
|
!!! attention
|
|
|
|
|
|
|
|
Access restriction requires iRedAPD plugin `sql_alias_access_policy`,
|
|
|
|
please make sure it's enabled in iRedAPD config file
|
|
|
|
`/opt/iredapd/settings.py`.
|
|
|
|
|
2015-02-01 05:22:03 -06:00
|
|
|
You can restrict which senders are allowed to send email to this mail alias
|
|
|
|
account by adding proper policy name in SQL column `alias.accesspolicy`.
|
|
|
|
For example:
|
|
|
|
|
|
|
|
```
|
2017-07-02 21:02:07 -05:00
|
|
|
sql> UPDATE alias SET accesspolicy='domain' WHERE address='alias@mydomain.com';
|
2015-02-01 05:22:03 -06:00
|
|
|
```
|
|
|
|
|
2017-07-02 21:02:07 -05:00
|
|
|
Available access policies:
|
|
|
|
|
|
|
|
Access Policy Name | Comment
|
|
|
|
--- |---
|
|
|
|
`public` | no restrictions
|
|
|
|
`domain` | all users under same domain are allowed to send email to this mail list.
|
|
|
|
`subdomain` | all users under same domain and all sub-domains are allowed to send email to this mail list.
|
|
|
|
`membersonly` | only members of this mail list are allowd.
|
|
|
|
`moderatorsonly` | only moderators of this mail list are allowed.
|
|
|
|
`membersandmoderatorsonly` | only members and moderators of this mail list are allowed.
|
|
|
|
|
|
|
|
### How to assign a moderator
|
|
|
|
|
|
|
|
Moderators are email addresses stored in SQL table `alias_moderators`. With
|
|
|
|
iRedAPD-1.4.5 and later releases, it's ok to use `*@domain.com` as (one of)
|
|
|
|
moderator for all users under mail domain 'domain.com'.
|
|
|
|
|
|
|
|
To assign user `someone@gmail.com` and `someone@outlook.com` as moderator of
|
|
|
|
mail alias `alias@mydomain.com`:
|
|
|
|
|
|
|
|
```
|
|
|
|
sql> INSERT INTO alias_moderators (address, moderator, domain, dest_domain)
|
|
|
|
VALUES ('alias@mydomain.com', 'someone@gmail.com', 'mydomain.com', 'gmail.com');
|
|
|
|
|
|
|
|
sql> INSERT INTO alias_moderators (address, moderator, domain, dest_domain)
|
|
|
|
VALUES ('alias@mydomain.com', 'someone@outlook.com', 'mydomain.com', 'outlook.com');
|
|
|
|
```
|
2015-02-01 05:22:03 -06:00
|
|
|
|
|
|
|
## See also
|
|
|
|
|
|
|
|
* [Create mailing list for OpenLDAP backend](./ldap.add.mail.list.html)
|