2015-12-14 22:56:35 -06:00
|
|
|
# SQL: User mail forwarding
|
|
|
|
|
|
|
|
[TOC]
|
|
|
|
|
2017-08-09 05:46:04 -05:00
|
|
|
!!! attention
|
|
|
|
|
|
|
|
* This document is applicable to iRedMail-0.9.7 and later releases.
|
|
|
|
* Here's [doc for iRedMail-0.9.6 and earlier releases](./sql.user.mail.forwarding-20170701.html).
|
|
|
|
|
2015-12-14 22:56:35 -06:00
|
|
|
## Set mail forwarding with iRedAdmin-Pro
|
|
|
|
|
|
|
|
With iRedAdmin-Pro, you can manage mail forwarding addresses in user
|
|
|
|
profile page, under tab `Forwarding`.
|
|
|
|
|
|
|
|
Screenshot:
|
|
|
|
|
2017-10-28 00:38:13 -05:00
|
|
|
![](./images/iredadmin/user_profile_mail_forwarding.png){: width=1000px }
|
2015-12-14 22:56:35 -06:00
|
|
|
|
|
|
|
## Set mail forwarding with SQL command line
|
|
|
|
|
2017-08-09 05:46:04 -05:00
|
|
|
Let's say you have an __existing__ mail user `user@domain.com`, and you want to
|
2015-12-14 22:56:35 -06:00
|
|
|
forward all received emails to another address `forward@example.com`,
|
|
|
|
to achieve this, you can login to SQL server and update `vmail` database like
|
|
|
|
below:
|
|
|
|
|
|
|
|
```
|
2017-08-09 05:46:04 -05:00
|
|
|
USE vmail;
|
2019-05-16 11:36:10 -05:00
|
|
|
INSERT INTO forwardings (address,
|
|
|
|
forwarding,
|
|
|
|
domain,
|
|
|
|
dest_domain,
|
|
|
|
is_forwarding,
|
|
|
|
active)
|
|
|
|
VALUES ('user@domain.com',
|
|
|
|
'forward@example.com',
|
|
|
|
'domain.com',
|
|
|
|
'example.com',
|
|
|
|
1,
|
|
|
|
1);
|
2015-12-14 22:56:35 -06:00
|
|
|
```
|
|
|
|
|
2017-08-09 05:46:04 -05:00
|
|
|
If you want to forward email to multiple addresses, please create more records
|
|
|
|
like above:
|
2015-12-14 22:56:35 -06:00
|
|
|
|
|
|
|
```
|
2017-08-09 05:46:04 -05:00
|
|
|
USE vmail;
|
|
|
|
|
|
|
|
-- Forwarding to address 'forward-2@example.com'
|
2019-05-16 11:36:10 -05:00
|
|
|
INSERT INTO forwardings (address,
|
|
|
|
forwarding,
|
|
|
|
domain,
|
|
|
|
dest_domain,
|
|
|
|
is_forwarding,
|
|
|
|
active)
|
|
|
|
VALUES ('user@domain.com',
|
|
|
|
'forward-2@example.com',
|
|
|
|
'domain.com',
|
|
|
|
'example.com',
|
|
|
|
1,
|
|
|
|
1);
|
2017-08-09 05:46:04 -05:00
|
|
|
|
|
|
|
-- Forwarding to address 'forward-3@example.com'
|
2019-05-16 11:36:10 -05:00
|
|
|
INSERT INTO forwardings (address,
|
|
|
|
forwarding,
|
|
|
|
domain,
|
|
|
|
dest_domain,
|
|
|
|
is_forwarding,
|
|
|
|
active)
|
|
|
|
VALUES ('user@domain.com',
|
|
|
|
'forward-3@example.com',
|
|
|
|
'domain.com',
|
|
|
|
'example.com',
|
|
|
|
1,
|
|
|
|
1);
|
2015-12-14 22:56:35 -06:00
|
|
|
```
|
|
|
|
|
|
|
|
To save a copy of forwarded email in mailbox, please add your own email address
|
|
|
|
as a forwarding destination like below:
|
|
|
|
|
2018-01-24 04:32:06 -06:00
|
|
|
!!! attention
|
|
|
|
|
|
|
|
This SQL record exists by default, but it's a good idea to make sure it
|
|
|
|
exists. If it exists, you will get error like `ERROR 1062
|
|
|
|
(23000): Duplicate entry 'user@domain.com-user@domain.com' for key
|
|
|
|
'address'`, don't panic.
|
|
|
|
|
2015-12-14 22:56:35 -06:00
|
|
|
```
|
2019-05-16 11:36:10 -05:00
|
|
|
INSERT INTO forwardings (address,
|
|
|
|
forwarding,
|
|
|
|
domain,
|
|
|
|
dest_domain,
|
|
|
|
is_forwarding,
|
|
|
|
active)
|
|
|
|
VALUES ('user@domain.com',
|
|
|
|
'user@domain.com',
|
|
|
|
'domain.com',
|
|
|
|
'domain.com',
|
|
|
|
1,
|
|
|
|
1);
|
2015-12-14 22:56:35 -06:00
|
|
|
```
|
2015-12-14 23:03:51 -06:00
|
|
|
|
|
|
|
## Related tutorial
|
|
|
|
|
|
|
|
* [LDAP: user mail forwarding](./ldap.user.mail.forwarding.html)
|