I'm trying to move spam mails to the junk folder automatically with a procmailrc file. Right now I've got postfix running with virtualmail, storing mailbox-settings etc in mysql:
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual-aliases.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual-domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual-mailboxes.cf
virtual_minimum_uid = 1111
virtual_uid_maps = static:1111
virtual_gid_maps = static:1111
virtual_mailbox_base = /home/vmail
I also got procmail as a virtual transport enabled:
virtual_transport = procmail
procmail_destination_recipient_limit = 1
main.cf:
procmail unix - n n - - pipe flags=DRXhuq user=vmail
argv=/usr/bin/procmail -m E_SENDER=$sender E_RECIPIENT=$recipient ER_USER=$user ER_DOMAIN=$domain ER_DETAIL=$extension NEXTHOP=$nexthop /etc/procmail.d/default.rc
Now in /etc/procmail.d/default.rc
I want to route mails to /home/vmail/[DOMAIN]/[USERNAME]
, where USERNAME is not the $recipient
or the $user
value but another value stored in my database.
Is there any way I can get that name from the database to procmail, so it can route mails correctly?
+----------+--------------+------+-----+---------------------------------------------------------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------------------------------------------------------------------+-------+
| domain | varchar(255) | NO | PRI | NULL | |
| email | varchar(255) | NO | PRI | NULL | |
| user | varchar(255) | NO | | NULL | |
| password | varchar(255) | NO | | {CRYPT}$2y$05$M93Wk.20E31Let6AsWvjx.5eEfsw3ZM1jpha/XkPq6O5PPaiDgc/6 | |
| location | varchar(255) | NO | | NULL | |
| quota | bigint | NO | | 10000000000 | |
| enabled | tinyint | NO | | 0 | |
+----------+--------------+------+-----+---------------------------------------------------------------------+-------+
the mail is delivered to /home/vmail/DOMAIN/user
where user is a custom username that doesn't need to be the same as the email.
SELECT * FROM [table] WHERE user = 'xyz';
+-----------+----------------------+------+---------------------------------------------------------------------+----------------+-------------+---------+
| domain | email | user | password | location | quota | enabled |
+-----------+----------------------+------+---------------------------------------------------------------------+----------------+-------------+---------+
| exam.ple | mymail | xyz | password | exam.ple/xyz/ | 50000000000 | 1 |