1

Topic: Catch for postmaster@, hostmaster@ and so on

Hi.

I have a small problem, and I'm not sure how to tackle it.
I have a few domains on the server, like domain1.net, domain2.com and so on.

How can I catch all mail sent to postmaster@domain1.net, hostmaster@xyz.com, abuse@asdsa.org and so on to be automatically redirected to corresponding addresses on the main domain?

I would like to do this without declaring aliases for each domain. Something that works "automagically", for existing domains and for other domains I will create in the future, without me needing to declare anything else.

Also, I want to receive only mails which were intended for abuse@, postmaster@, not for all existing or non-existing addresses.

Any clues?

Thanks!

----

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

2

Re: Catch for postmaster@, hostmaster@ and so on

Search 'postfix catchall' in Google, and you will get answer. Postfix supports this. smile

And here is another reference: http://www.cyberciti.biz/faq/howto-setu … -accounts/

Good luck smile

3

Re: Catch for postmaster@, hostmaster@ and so on

Yes, I saw those ones, unfortunately it won't work, because I have a MySQL backend, so /etc/postfix/virtual is not used, and I shouldn't enable it.

Hmmm, lemme see if I can put something in the database. I hope I won't crash postfix... tongue

4

Re: Catch for postmaster@, hostmaster@ and so on

maxie_ro wrote:

I have a MySQL backend, so /etc/postfix/virtual is not used

You can use multiple mysql query table, such as:

virtual_mailbox_maps = hash:/etc/postfix/virtual, mysql:/etc/xxx

5 (edited by maxie_ro 2009-11-18 19:36:14)

Re: Catch for postmaster@, hostmaster@ and so on

Solution found.

For iRedOS 5.0:
1. Create new table in database vmail:

CREATE TABLE `vmail`.`common_alias` (
  `address` VARCHAR(128) NOT NULL COMMENT 'Received base address (without domain part)',
  `goto` VARCHAR(128) NOT NULL COMMENT 'Where to redirect (domain part MUST be included)',
  `created` DATETIME DEFAULT NULL,
  `modified` DATETIME DEFAULT NULL,
  `expired` DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
  `active` BOOLEAN NOT NULL DEFAULT 0,
  PRIMARY KEY (`address`)
)
ENGINE = MyISAM
CHARACTER SET utf8 COLLATE utf8_general_ci
COMMENT = 'Common aliases for all domains';

2. Populate the above table with the values you need, for example:

INSERT INTO `common_alias` SET `address`='postmaster', `goto`='postmaster@example.com', `created`=NOW(), `modified`=NULL, `expired`='9999-12-31 00:00:00', `active`=1;

INSERT INTO `common_alias` SET `address`='abuse', `goto`='abuse@example.com', `created`=NOW(), `modified`=NULL, `expired`='9999-12-31 00:00:00', `active`=1;

INSERT INTO `common_alias` SET `address`='hostmaster', `goto`='hostmaster@example.com', `created`=NOW(), `modified`=NULL, `expired`='9999-12-31 00:00:00', `active`=1;

INSERT INTO `common_alias` SET `address`='webmaster', `goto`='webmaster@example.com', `created`=NOW(), `modified`=NULL, `expired`='9999-12-31 00:00:00', `active`=1;

3. Create file /etc/postfix/mysql_virtual_common_alias_maps.cf, with the following contents:

user                = vmail
password    = your_password_here
hosts            = 127.0.0.1
port                = 3306
dbname        = vmail
query            =  SELECT goto FROM common_alias WHERE address = '%u' AND active='1' AND expired >= NOW() AND '%d' IN (SELECT domain FROM domain WHERE domain='%d');

Be sure to modify "your_password_here" with your real password for user vmail.

4. Modify the entry in /etc/postfix/main.cf to include the new map:

virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_common_alias_maps.cf, mysql:/etc/postfix/mysql_virtual_alias_maps.cf

If you use proxymap, adapt it for proxymap.

5. Test it.


P.S.
ZhangHuangbin, you should include this in the next version/hotfix. tongue

6

Re: Catch for postmaster@, hostmaster@ and so on

maxie_ro wrote:

ZhangHuangbin, you should include this in the next version/hotfix.

I will consider merge it in next version, but it's not a hotFIX. smile

Thanks for your testing and contribution smile