Install Postfix on Ubuntu 20 LTS for Email communication from Web site

Postfix is ​​a popular open source mail transfer agent (MTA) that can be used to route and deliver email on Linux systems. It is estimated that approximately 25% of public mail servers on the Internet run Postfix.

In this guide, you will learn how to install and configure Postfix on an Ubuntu 20.04 server. Then, you will install s-nail (Mail User Agent (MUA), also known as email client) to test whether Postfix can route mail correctly.



apt install postfix





Give the name and save it.

You can config postfix like all services in Ubuntu


/etc/postfix/



First config is SPF and DKIM


vim main.cf


Add external IP of your site in mynetworks for example


myhostname = vindazo.de

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 88.99.98.110


Don’t forget to check Reverse DNS for this IP. It should be the same as your site domain.


apt -y install opendkim


vim /etc/opendkim.conf


Domain *

KeyFile /etc/dkimkeys/default

Selector mail


ExternalIgnoreList /etc/opendkim/TrustedHosts

InternalHosts /etc/opendkim/TrustedHosts


Generate keyfile

openssl rsa -in dkim.private.key -out dkim.public.key -pubout -outform PEM


Copy content in /etc/dkimkeys/default


-----BEGIN RSA PRIVATE KEY-----

.. q7iFoEFmbaORdWDFTFf4gf4nevXmdGO

RQ0Tmf/PlQPPJhv3+oBs3Bs+WBAOIdrJVyEsPL5/Ra2p

-----END RSA PRIVATE KEY-----



vim /etc/opendkim/TrustedHosts



127.0.0.1

localhost

domain.be




vim master.cf


vindazode unix - - n - - smtp

-o syslog_name=vindazode

-o smtp_helo_name=vindazo.de

-o smtp_bind_address=88.99.98.233





vim main.cf

If you have more than one domain on one host then you can rout mail traffic with regexp file..



sender_dependent_default_transport_maps = regexp:/etc/postfix/sdd_transport_maps.regexp


Vim sdd_transport_maps.regexp


/@vindazo\.de$/ vindazode:





chmod 0600 /etc/dkimkeys/default

Comments