Posts

Showing posts with the label Postfix

Configure Alias (Auto BCC) in Postfix

Sometimes we have to set auto forwarding in between addresses. For example, a department head shall get all the inbound emails received by his team members. We can achieve such target using aliases of postfix. Step 1: Create an alias file including its’ database. By default there is an aliases file in the server. If not, please proceed as below. root@mail:~# touch /etc/postfix/aliases root@mail:~# postalias /etc/postfix/aliases Step 2: Open the aliases file and set necessary aliases as required. root@mail:~# vim /etc/postfix/aliases user1: user1,hod user2: user2,hod   Step 3: Update database. root@mail:~# postalias /etc/postfix/aliases This alias acts like auto BCC. In this case user1, user2 shall not get any notification of this forwarding.

Postfix and Dovecot Based Email Server Configuration with SMTP Authentication

Image
Objective: Configuring a mail server using Postfix MTA, Dovecot MDA and Squirrelmail webmail. We are using the below information to configure the mail server. Domain Name: learnandgains.com Server Hostname: mail.learnandgains.com IP address: 192.168.22.30 OS: Ubuntu 20.04 LTS   Server Readiness: root@ubuntu:~# dpkg-reconfigure tzdata (Set the Geographic area: Asia, Time zone: Dhaka) root@ubuntu:~# apt install ntpdate root@ubuntu:~# ntpdate bd.pool.ntp.org root@ubuntu:~# sudo timedatectl set-ntp off root@ubuntu:~# date (To check the current date in the server)   root@ubuntu:~# vim /etc/hostname mail.learnandgains.com   root@ubuntu:~# vim /etc/hosts 192.168.22.30 mail.learnandgains.com  mail   root@ubuntu:~# apt update root@ubuntu:~# apt upgrade –y root@ubuntu:~# reboot Configuring Postfix: root@mail:~# apt install postfix root@mail:~# dpkg-reconfigure postfix Configuring Dovecot: root@mail:~# apt install dovecot-core do...

Set Auto Reply/Vacation Resonder using Procmail

We can set auto reply/vacation responder in multiple ways e.g. Webmail or Procmail. It is very easy to set vacation responder using webmail. However, if your webmail does not support vacation responder, you can achieve the target using procmail. Step 1: Install procmail if not installed previously. root@mail: apt install procmail Step 2: Change directory to user1 where an auto reply message shall be set. root@mail:cd /home/user1 Create a file .procmailrc in this directory. root@mail:vim /home/user1/.procmailrc SHELL=/bin/sh         :0 h c             * !^FROM_DAEMON             * !^X-Loop: ​ user1@domain.com        | (formail -r -I"Precedence:junk" \ -A"X-Loop:   user1@domain.com" ; \              ...

Procmail Configuration with Postfix

Procmail is a Mail Delivery Agent (MDA) which can sort out incoming/outgoing email. It can differentiate emails based on the keyword, from/to address etc. and deliver the email to respective inbox or discard it based on the policy. It is a very useful MDA for sorting out emails. Step 1: Create three users e.g. allmail, incoming and outgoing. allmail =   It contains all incoming and outgoing emails. incoming = It contains only inbound emails from outside domain. outgoing = It contains the outbound emails send from the self-domain to any recipient domain. root@mail:~# adduser allmail root@mail:~# adduser incoming root@mail:~# adduser outgoing Step 2: Install procmail. root@mail: apt install procmail Step 3: Create a file .forward to forward all emails to procmail. root@mail:/home/allmail#vim .forward |/usr/bin/procmail Step 4: Create another file .procmailrc to forward inbound and outbound emails to respective email accounts. root@...

Troubleshooting - Postfix Empty Mail Log

Few days back I faced a problem in getting e-mail log from /var/log/mail.log. I found the mail.log file is empty and not showing any email log. After that I analyzed the issue and found that mail.log file has the permission like below: -rw-r-----   1 root     adm      0K Dec 12 00:15 mail.log I immediately changed the ownership using below command and restarted rsyslog, postfix service. #chown syslog:adm /var/log/mail.log #service rsyslog restart #service postfix restart Then, after executing the command “tail –f /var/log/mail.log”, I found the e-mail log showing properly.

Webmin Installation on Debian and Ubuntu

Image
We, the system administrator, always try to simplify our work. By default, a Debian/Ubuntu server edition do not provide us GUI version to manage the system e.g. Postfix based mail server, proxy server etc. We can achieve it using webmin. This guide will drive us to the installation of webmin in a Postfix based mail server. Deployment Infrastructure: OS: Ubuntu/Debian Installation: If you are using the DEB version of webmin run the command: wget https://prdownloads.sourceforge.net/webadmin/webmin_1.941_all.deb (install the latest package from: http://www.webmin.com/download.html) Run the command: dpkg --install webmin_1.941_all.deb The install shall be completed automatically to /usr/share/webmin, the administration username set to root and the password to your current root password. You should now be able to login to Webmin. Login URL: http://serveripaddress:10000 If Debian complains about missing dependencies, you can install th...