How to automatically forward mail with Postfix/Dovecot?
Solution 1
You have to certify that you have an alias_map
or alias_database
entry in your main.cf
:
alias_database = hash:/etc/aliases
then, inside that file set you alias as desired:
someaddress: [email protected]
after that run newaliases
and you are good to go.
Solution 2
Maybe a bit late, but here's one really pleasant post on how to set mail forwarding with Postfix/Dovecot through the virtual_alias_map
parameter:
https://geekpeek.net/configure-postfix-mail-forward/
where this article is tightly related to another one by the same author, which can be found here. I recommend checking them out both, because they refer each other too much anyway.
So it seems that the right way to do forwarding it through the virtual alias class and the virtual_alias_map
parameter.
Full documentation on the virtual alias class can be found in the Postfix's docs reference here and here, and an example here.
So here's what Postfix say:
The virtual alias domain class.
Purpose: hosted domains where each recipient address is aliased to a local UNIX system account or to a remote address.
And finally the mail forwarding example:
Mail forwarding domains
Some providers host domains that have no (or only a few) local mailboxes. The main purpose of these domains is to forward mail elsewhere. The following example shows how to set up example.com as a mail forwarding domain:
1 /etc/postfix/main.cf: 2 virtual_alias_domains = example.com ...other hosted domains... 3 virtual_alias_maps = hash:/etc/postfix/virtual 4 5 /etc/postfix/virtual: 6 [email protected] postmaster 7 [email protected] joe@somewhere 8 [email protected] jane@somewhere-else 9 # Uncomment entry below to implement a catch-all address 10 # @example.com jim@yet-another-site 11 ...virtual aliases for more domains...
Source: http://www.postfix.org/VIRTUAL_README.html#forwarding
Related videos on Youtube
Mohd Mobeen
Updated on September 18, 2022Comments
-
Mohd Mobeen over 1 year
my query is
INSERT INTO `session_card` (`flags`, `history`, `showtime`, `session_id`, `card_id`, `card_mode`) VALUES ('', 'ö', '12', 9410, '256', 'rw')
and the table structure is
DROP TABLE IF EXISTS `session_card`; CREATE TABLE IF NOT EXISTS `session_card` ( `id` int(11) NOT NULL, `session_id` int(11) DEFAULT NULL, `card_id` int(100) DEFAULT NULL, `history` varchar(1000) DEFAULT NULL, `flags` varchar(255) NOT NULL DEFAULT '', `showtime` varchar(2000) DEFAULT NULL, `card_mode` varchar(10) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`), UNIQUE KEY `session_card_unique_key` (`session_id`,`card_id`,`card_mode`), KEY `fk` (`session_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
COMMIT;
Now I dont understand what is the issue here also my phpmyadmin show only error code it doesnt give me the error expatiation. Any one can help me with this.
-
fboaventura about 11 yearsCan you post your
postconf -n
? Have you tried withalias_map
? -
Davis Sorenson about 11 years
-
fboaventura about 11 yearsHave you checked the file
mysql-virtual_email2email.cf
and the table associated with it? -
Krishna Yadav over 6 yearsIf you are using this table, then for inserting you are calling a method for insertion, then in that method make a counter which takes the last value from this table of id and increament it with 1 or any value which you are using it...then assign that value to the id column and other value as you are inserting in it
-
Mohd Mobeen over 6 yearsphpmyadmin show only error code it doesnt give me the error expatiation. Could you please help me with that
-
M. Eriksson over 6 years@MohdMobeen - You can always use Google to find what the error code means. I don't use PHPMyAdmin so I can't help you with that part.
-
M. Eriksson over 6 yearsSo basically you're advocating for handling the auto increment manually (which includes extra database calls) instead of letting the database do it for you? If you have 2 rows with id 1 and 2. You delete the row with id 2. Next time you insert a new row, that row would get id 2 as well. Any references (old links etc) that contains that id will now show the wrong record.
-
Krishna Yadav over 6 years@MagnusEriksson By making function and trigger which can take the last value of id which is highest and increament it by 1 or any other value then insert it
-
M. Eriksson over 6 yearsThat wouldn't solve the issue I just mentioned and I still don't get the reasoning behind doing that manually? There's absolutely no reason for it. Just add AUTO_INCREMENT on that column and let the database take care of it for you.