Image

Knowledge base → Setting up a mail collector in postfixAdmin

[Virtual servers]
Date of publication: 07.06.2023

In order to connect and configure the mail collector, we need to set up a script that will access the postfixAdmin database and, based on the parameters specified there, collect mail from another mail server. Since by default this option does not have a connection with the mail server, we will make this functionality work.

1. Add an account and collect mail in postfixAdmin

https://mydomain.tld/postfixadmin/public/edit.php?table=fetchmail


2. Let's make changes to the script, specifying the parameters for connecting to the database:

nano /usr/local/bin/fetchmail.pl
...

database settings

database backend - uncomment one of these

our $db_type = 'mysql';

host name

our $db_host="127.0.0.1";

database name

our $db_name="postfix";

database username

our $db_username="postfix";

database password

our $db_password="postfix1HuRaf92"; ...

3. Installing the necessary packages, in case of an error when running the script

chmod +x /usr/local/bin/fetchmail.pl

apt install libdbd-pg-perl libdbd-mysql-perl libdbd-syslog-perl liblogger-syslog-perl liblockfile-simple-perl

3.1 Add a task to cron

crontab -e

*/2 * * * * /usr/local/bin/fetchmail.pl

Now you can activate our settings in step 1 and check the work. In our example, we made a setting so that the script picks up only new ones, i.e. unread letters, so we get rid of duplicates. After collecting new messages, the script will mark them as read on the remote server.





No Comments Yet