Configure Postfix SMTP mail Server in Linux

This is "How to" install and configure SMTP mail server using Postfix . This configurations should work in all RPM based linux distributions (Redhat, CentOS, Fedora, etc.)

Step1:Install postfix via yum (in latest CentOS/Redhat it will be preinstalled, perform a fresh install postfix in Fedora and CentOS5 or older)
Verify the postfix is installed by default by below command
[root@server ~#]rpm -q postfix
[root@server ~#]yum install postfix              (can use this command  update to latest if postfix is preinstalled)

Step2: Edit the postfix configuration file " /etc/postfix/main.cf " is a file with 676 lines 
[root@server ~#]vi /etc/postfix/main.cf

# in the 75th line, uncomment by removing "#" and specify your required hostname (hostname is used with mail id, so email IDs will be look like user@servercomputing.tech)
myhostname = servercomputing.tech

#in the 83rd line, uncomment and specify your domain name
mydomain = tech

#in the 99th line, enable it (remove #)
myorigin = $mydomain

#In 116th line, specify interfaces which server allows requests(you can set to all or any specific network interfaces) 
inet_interfaces = all

#in the 119th line specify the ip version (ipv4 or ipv6)
inet_protocols = ipv4

#in the 164th line, change like below
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

#In the 264th line, enable the line and add your client network( if 192.168.10.0/24)
mynetworks = 127.0.0.0/8, 192.168.10.0/24

#in 418th line, enable the line and edit like below
home_mailbox = Maildir/

#In 545th line, enable the line by removing the "#"
header_checks = regexp:/etc/postfix/header_checks

#In 546th line, add like below
body_checks = regexp:/etc/postfix/body_checks

#In 571th line, add like below
smtpd_banner = $myhostname ESMTP

#Add the following 7 lines to bottom of the file (last two lines are actually 1 line)
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_client_restrictions = permit_mynetworks,reject_unknown_client,permit
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject


#(Now save the main.cf file)

Step3: Edit /etc/postfix/header_checks file
[root@server ~#]vi /etc/postfix/header_checks

#in the 330th line add the following 2 lines       (just below to  line:   "header_checks" )
/^From:.*<#.*@.*>/ REJECT
/^Return-Path:.*<#.*@.*>/ REJECT
(save the header_checks file)

Step4: create a new file named body_checks in /etc/postfix/
[root@server ~#]vi /etc/postfix/body_checks

#Add the below one line
/^(|[^>].*)example.com/ REJECT

#(Save the body_checks file)

Step5:Start/Restart the postfix daemon
[root@server ~#]service postfix start


[Important: By default postfix server will listen on port 25/TCP. So you should open this port is firewall or click here to Disable Linux firewall.]


Continue building your Mail server
Related Topics:How to configure POP/IMAP server using Dovecot in Linux  (Click Here)
Related Topics:Final Configurations after configuring Postfix and Dovecot (Click Here)

Was this helpfull ?

1 comments:

Menno Vos said...

Thanks for this configuration!
Maybe you can help me, I've a strange problem.

My SMTP server seems to act good, but…

I use filemaker to send me warnings on user actions. In the moment I get more then 4 warnings it refuses to send me the 5th one.

If I wait between 30s-1 minute it will send me again the warning.

The problem is not in Filemaker I guess because if I use smtp from gmail all is working fine.

Hope you can help, looking already days for a solution ;-)

Related Posts Plugin for WordPress, Blogger...

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons