This is a simple maildrop filter which filters incoming messages by the sender address and move it to the corresponding folder. E-Mail address and destination folder are both defined in a MySQL table.
This example is used in an uberspace environment.
For convenience we use the already existing database corresponding to your uberspace account (e.g. your uberspace username is melanie there will be already a database called melanie.
mysql $USER << '__EOF__'
CREATE TABLE `mailfilter` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`folder` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
__EOF__
Below you will find a single sample entry which will move e-mails from [email protected] to the folder Your_IMAP_Folder:
mysql $USER << '__EOF__'
INSERT INTO mailfilter (email, folder) VALUES ('[email protected]', 'Your_IMAP_Folder');
__EOF__
It is important that you have read and understood the basic configuration hints from the uberspace maildrop support wiki.
You can use the below-mentioned script as your maildrop filter rule or enhance your existing script by adding the if ( /^From:\s*(.*)/ ) code block. As mentioned before we are using the database corresponding to your uberspace account. So you have to change the variable DATABASE to your username.
Last but not least be sure you set the correct rights to the filter rule (e.g. chmod 600 ~/.myfilter).
(Thx to Jonas from uberspace for his feedback)