How to configure postfix as a SMTP mail server in fedora

In order to configure postfix as a SMTP mail server in fedora, please follow this process

Process

1. Execute the next command from the console to install postfix

[abernal@sandbox ~]$ sudo dnf install postfix

2. Execute the next command to install mailx

[abernal@sandbox ~]$ sudo dnf install mailx

3. Check that port 587 is not bloqued by a firewall (default firewall : iptables)

​[abernal@sandbox ~]$ sudo iptables -L | grep 587

​4. Open the postfix master.cf file

​[abernal@sandbox ~]$ sudo vim /etc/postfix/master.cf

5. Uncomment the "submission" line and all the overwrites you find under it. The overwrites start with a few spaces and the character -o

submission inet n       -       n       -       -       smtpd

  -o syslog_name=postfix/submission

  -o smtpd_tls_security_level=encrypt

  -o smtpd_sasl_auth_enable=yes

  -o smtpd_reject_unlisted_recipient=no

#  -o smtpd_client_restrictions=$mua_client_restrictions

#  -o smtpd_helo_restrictions=$mua_helo_restrictions

#  -o smtpd_sender_restrictions=$mua_sender_restrictions

#  -o smtpd_recipient_restrictions=

  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject

  -o milter_macro_daemon_name=ORIGINATING

​6. Open postfix's main.cf file

​[abernal@sandbox ~]$ sudo vim /etc/postfix/main.cf

​7. Set the Fully Qualified Domain Name in postfix's main.cf file

myhostname = mail.apps.alejandrobernalcollazos.com

​8. Set the $myorigin variable in postfix's main.cf file

myorigin = $mydomain

​9. Start postfix service executing the next command

[abernal@sandbox ~]$ sudo postfix start

10. Test the configuration

[abernal@sandbox ~]$ mail -s "Hello World" someone@example.com
Cc:
Hi Peter
How are you
I am fine
Good Bye
<Ctrl+D>

11. Create the SSL Certificate folder (certs) within /etc/postfix

[abernal@sandbox postfix]$ sudo mkdir certs

12. Create the SSL Certificate (sample)

[abernal@sandbox postfix]$ sudo openssl req -new -x509 -days 3650 -nodes -out /etc/postfix/certs/cert.pem -keyout /etc/postfix/certs/key.pem

Generating a 2048 bit RSA private key
...+++
.............................................+++
writing new private key to '/etc/postfix/certs/key.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:AR
State or Province Name (full name) []:Cordoba
Locality Name (eg, city) [Default City]:Cordoba
Organization Name (eg, company) [Default Company Ltd]:Asys
Organizational Unit Name (eg, section) []:development
Common Name (eg, your name or your server's hostname) []:apps.alejandrobernalcollazos.com
Email Address []:alejandro@alejandrobernalcollazos.com

13. Modify postfix's main.cf file

[abernal@sandbox ~]$ sudo vim /etc/postfix/main.cf

14. Set these SSL variables

# TLS certificate parameter
 smtpd_tls_key_file = /etc/postfix/certs/key.pem
 smtpd_tls_cert_file = /etc/postfix/certs/cert.pem

15. Reload Postfix executing this command

[abernal@sandbox ~]$ sudo postfix reload

Reference document : http://www.shisaa.jp/postset/nikola-web.html