tutorials questions & answers
by Pinkman

Install Postfix on CentOS

TAGS:
  • MAIL
  • postfix
  • smtp

Download Postfix

First lets start with updating the system

Yum update -y

Now we are going to install postfix

Yum install postfix cyrus-sasl-plain -y

If it is already installed, we can continue with the configuration of postfix

Now we have to set Postfix as our default MTA

alternatives --set mta /usr/sbin/sendmail.postfix

Configure Postfix

Now we are going to edit the configuration file of Postfix. Open this file with your favorite text editor In this case i will be using Nano If you want to use nano too, install it with:

yum install nano -y
nano /etc/postfix/main.cf

Paste the following at the bottom of the file:

mynetworks = 127.0.0.0/8, 10.11.1.0/24 relayhost = [mail.example.com]:587 smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_tls_CApath = /etc/ssl/certs smtp_use_tls = yes

Replace mail.example.com with the SMTP server of your mail domain In this guide i will be using the SMTP server of GMAIL (smtp.gmail.com) Let the brackets [ & ] stay in the relayhost.

Save and exit the file

Now we need to create the file with our username and password of our email account

nano /etc/postfix/sasl_passwd

Add the following to the new file

[smtp.gmail.com]:587 youremailaddress:yourpassword

example: [smtp.gmail.com]:587 test@gmail.com:password123

Save and exit the file

Change the permissions of the file with the following command

chmod 0600 /etc/postfix/sasl_passwd

Execute the following command to put the new changes into postfix

postmap /etc/postfix/sasl_passwd

Run the following command to check the configuration of postfix

postfix check

If you do not get any errors, then the configuration syntax is okay

Lets restart postfix to make it active with the new configuration

Service postfix restart

Install the mail command with the following command

yum install mailx -y

Test Postfix

Send yourself a test email with the following command

echo test | mail -s TEST youremailaddress@yourdomain.com

If you received the email, the postfix installation has succeeded.

comments (0)

    leave comment

    Please choose login or register to comment in this thread.

    Start now for as low as $4,99 a month!

    • 8 Characters2
    • 1 Uppercase Atleast
    • 1 Number Atleast