I have setup postfix to use virtual users for inbound emails, with the configuration read from mysql.
However, when I try to deliver a mail locally, using something like
sendmail root@localhost < testmail, the queries are being executed, but the mail is not delivered to the virtual user directory.
/var/mail/root is created instead.
Mysql config seems correct, as the following queries are executed:
SELECT destination FROM aliases WHERE mail='root@localhost' and enabled = 1 +----------------+ | destination | +----------------+ | root@localhost | +----------------+ SELECT destination FROM aliases WHERE mail='localhost' and enabled = 1; Empty set (0.00 sec) SELECT domain FROM domains WHERE domain='localhost' and enabled = 1; +-----------+ | domain | +-----------+ | localhost | +-----------+
But they seem to be ignored.
When trying to login through courier IMAP, this results in the following:
1 login root@localhost <password> * BYE [ALERT] Fatal error: No such file or directory: No such file or directory
because the folder that postfix created is not the one set in the DB for the user.
(largely inspired from a guide):
alias_database = hash:/etc/postfix/aliases alias_maps = hash:/etc/postfix/aliases append_dot_mydomain = no biff = no config_directory = /etc/postfix mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mynetworks_style = host myorigin = /etc/mailname readme_directory = no recipient_delimiter = + # working relayhost config here smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, permit smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination smtpd_sender_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining, permit virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf virtual_gid_maps = static:5000 virtual_mailbox_base = /var/spool/mail/virtual virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf virtual_mailbox_maps = mysql:/etc/postfix/mysql_mailbox.cf virtual_uid_maps = static:5000