1

Topic: domain forwarding relay

==== Required information ====
- iRedMail version (check /etc/iredmail-release): /etc/iredmail-release
- Linux/BSD distribution name and version: Centos 6.9
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): Mysql
- Web server (Apache or Nginx): Apache
- Manage mail accounts with iRedAdmin-Pro? yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
Trying to retire an old mail server where I have several domains that does wildcard forwarding using postfix, mysql, procmail.
source = %@domain1.tld destination = @domain2.tld (NOTE; domain 2 is an internet domain not on local server)
that will forward "user"@domain1.tls to "user"@domain2.tld

How can I do the same on ired?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: domain forwarding relay

iRedMail uses Postfix too, so ideally you can copy the config on old server to iRedMail.

It's better share with us how you get this working on old server, detailed Postfix config please.

3

Re: domain forwarding relay

ZhangHuangbin wrote:

iRedMail uses Postfix too, so ideally you can copy the config on old server to iRedMail.

It's better share with us how you get this working on old server, detailed Postfix config please.

Here is what is on my old server done by another guru on postfix many years ago.
---------------------
I have a table "users" with a destination field for the mailbox called
"to_ext"
I created 2 files to be able to forward email to external addresses
using wildcard.
Let me know if you implement this so I can have you update my server.
I really would like to rite that old server but I have several forwarded
domains I can not do on my ired pro.

Here are some of the records:
many to many with wildcard

email              to_ext                    status      domain_id.....
%@domain1.tld      @domain.elsewhere.tld     Forward     1

result
user1@domain1.tld  is forwarded to    user1@domain.elsewhere.tld
user2@domain1.tld  is forwarded to    user2@domain.elsewhere.tld

email              to_ext                    status      domain_id.....
%@domain1.tld      user1@domain.elsewhere.tld     Forward     1

Any user in domain1.tld is forwarded to user1@domain.elsewhere.tld

domain.elsewhere.tld can be local or any domain on the internet

Status:    The status this user will have,

Normal = delivery locally to the mailbox set in To_External field,
Forward = (to forward this email to somewhere else) MUST enter data into
To External field, ie: email address to forward the email to. Moved (to
alert the sender this email has moved to somewhere else) MUST enter data
into To External field, ie:new_email@address.com or unknown
(* Mail Box)

To External:    This field should have the the Mail Box directory name the
mail should be delivered to.
* If left blank the system will automatically use the Username. It also
should contain data if the status field is either Forward
(Email@address.to.forward) or Moved to (tipically UNKNOWN) Email will
bounce back to sender with this notation.
Use this field to alias the user to some other local mailbox, ie:
postmaster@domain.tld to user "jdoe" or abuse@domain.tld to user mailbox
"lsmith".(The local mailbox MUST exist)

here is my mysql query files.

virtual_forwards.cf
# Database lookup for "Forwarded Virtual Aliases", eg. email destinations
# in virtual domains that we host, but which are to be forwarded
someplace else
# Key is Recipient Address
# Result is remote email address
# Using the LIKE statement reversed allows us to put SQL wildcards (%,_)
# into the database...
user         = postfix
password     = xxxxxxxxx
dbname       = postfix2
hosts        = 127.0.0.1
query        = SELECT users.to_ext FROM domains,users WHERE
users.status='forward' AND domains.type='virtual' AND domains.id =
users.domain_id AND '%s' LIKE users.email
----------------------------------
relocated.cf
# Database lookup "Relocated" adresses.
# Key is Recipient Address
#
# Using the LIKE statement reversed allows us to put SQL wildcards (%,_)
# into the database...
# the to_ext column contains the new email address or any message like the word "UNKNOWN"
#The email will bounce with a message:
#Recipient address rejected: User has moved to "UNKNOWN"

user         = postfix
password     = xxxxxxxxxxxx
dbname       = postfix2
hosts        = 127.0.0.1
query        = SELECT users.to_ext FROM users WHERE users.status='moved'
AND '%s' LIKE users.email

Here is the portion of the main.cf file
# ADDRESS REDIRECTION (VIRTUAL DOMAIN)
#
# The VIRTUAL_README document gives information about the many forms
# of domain hosting that Postfix supports.
virtual_alias_maps =
proxy:mysql:$config_directory/mysql/virtual_aliases.cf,
proxy:mysql:$config_directory/mysql/virtual_forwards.cf
virtual_alias_domains =
proxy:mysql:$config_directory/mysql/virtual_domains.cf

# "USER HAS MOVED" BOUNCE MESSAGES
# See the discussion in the ADDRESS_REWRITING_README document.
relocated_maps = proxy:mysql:$config_directory/mysql/relocated.cf