How to install postfix mail on centos 7
Here's a step-by-step guide to installing and configuring Postfix mail server on CentOS 7:
Step 1: Install Postfix
Open a terminal and run the following command to install Postfix:
sudo yum install postfix
This will install the Postfix package and its dependencies.
Step 2: Configure Postfix
Postfix configuration files are located in the /etc/postfix
directory. You'll need to edit the main configuration file, main.cf
, to set up your mail server.
Run the following command to edit the main.cf
file:
sudo nano /etc/postfix/main.cf
Add the following lines to the end of the file:
myhostname = your_hostname
mydomain = your_domain
mydestination = $myhostname, $mydomain
mynetworks = 127.0.0.0/8 [::1]/128
Replace your_hostname
and your_domain
with your actual hostname and domain name.
Step 3: Create a Postfix user and group
Create a new user and group for Postfix:
sudo useradd -r postfix
sudo groupadd postfix
Step 4: Set ownership and permissions
Set the ownership and permissions for the Postfix configuration files:
sudo chown -R postfix:postfix /etc/postfix
sudo chmod -R 750 /etc/postfix
Step 5: Start and enable Postfix
Start the Postfix service and enable it to start automatically on boot:
sudo systemctl start postfix
sudo systemctl enable postfix
Step 6: Configure the Postfix daemon
Edit the Postfix daemon configuration file, master.cf
, to allow the daemon to listen on port 25:
sudo nano /etc/postfix/master.cf
Add the following line to the end of the file:
25 inet n - - - smtpd
Step 7: Restart Postfix
Restart the Postfix service to apply the changes:
sudo systemctl restart postfix
Step 8: Test Postfix
Use the telnet
command to test Postfix:
telnet localhost 25
You should see a response from Postfix indicating that it's listening on port 25.
Step 9: Configure your mail client
Configure your mail client (e.g., Thunderbird, Outlook) to use your Postfix mail server. You'll need to set the server name to localhost
or your_hostname
, and the port to 25
.
That's it! You should now have a basic Postfix mail server up and running on your CentOS 7 system.