1 (edited by GenZod 2019-05-28 07:05:12)

Topic: Virtual email aliases with a traditional flat-file

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): v0.9.9
- Deployed with iRedMail Easy or the downloadable installer?  Installer
- Linux/BSD distribution name and version: FreeBSD
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hi, alot of the threads/posts about email aliases results in using either MySQL or LDAP backend to do it. If you are like me using the free version of iRedMail, this can be tricky. Adding an email alias or a bunch of them via SQL/LDAP can be a tedious thing. Luckily there is an alternate way using the old traditional method of adding virtual aliases.

Only thing you need is to create a new virtual alias maps file and add in the virtual aliases in there. E.g:

INFO:
virtual domain = abc.com
virtual alias file = /usr/local/etc/postfix/yada_maps (/etc/postfix/ on Linux)
yada_maps:
tom@abc.com tom@xyc.com
jane@abc.com jane@someemail.com

Then 'postmap yada_maps' so it creates the hash db file called 'yada_maps.db'. You need to run the postmap command everytime you make changes in the file.

Next edit the main.cf file and look for this line:

virtual_alias_maps =
    proxy:mysql:/usr/local/etc/postfix/mysql/virtual_alias_maps.cf

Change it to look like this:
virtual_alias_maps =
    proxy:mysql:/usr/local/etc/postfix/mysql/virtual_alias_maps.cf,hash:/usr/local/etc/postfix/yada_maps

Then reload postfix with 'postfix reload'

Now you can test by sending an email from an external source and while doing it check the mail logs.

Good luck.
- Zod

----

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

2

Re: Virtual email aliases with a traditional flat-file

I do not recommend using flat file in this case.

- Storing in SQL is easier, just 1-2 (or more, depends on your requirements) SQL commands - we have tutorials for you. https://docs.iredmail.org/

- When you need to use iRedAdmin(-Pro) to create user, iRedAdmin(-Pro) does NOT know the addresses you stored in flat file, this may cause duplicate accounts and you will feel confused why the mail flow doesn't work as expected.

So, just use the SQL storage.

3

Re: Virtual email aliases with a traditional flat-file

ZhangHuangbin wrote:

I do not recommend using flat file in this case.

- Storing in SQL is easier, just 1-2 (or more, depends on your requirements) SQL commands - we have tutorials for you. https://docs.iredmail.org/

- When you need to use iRedAdmin(-Pro) to create user, iRedAdmin(-Pro) does NOT know the addresses you stored in flat file, this may cause duplicate accounts and you will feel confused why the mail flow doesn't work as expected.

So, just use the SQL storage.

Thanks for clearning that up. Just fyi that I use this on my server as I'm not using iRedAdmin-Pro and neither do I store aliases in the db. I also do not want to deal with SQL commands to add aliases so the flat-file aproach is most viable to me.

I have tested this with a virtual alias that also happens to have a virtual mailbox of the same email address. They both receive email sent to them externally.

Regards,
Zod