This is Postfix configuration on CentOs/Linux with relay, Usually people want to send bulk mail with mail server, so it will really help this post
----------------------------------------------------------------------------------------------------
yum install postfix
* then change default main.cnf to main.cnf.Bak, your config file as follows: /etc/postfix/main.cf
---------------------------------------------------------------------------
myhostname = mail.example.com
mydomain = mail.example.com
myorigin = $mydomain
smtpd_banner = $myhostname ESMTP $mail_name
biff = no
append_dot_mydomain = yes
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = localdomain, localhost, localhost.localdomain, localhost.$mydomain, $mydomain
mynetworks = 202.78.56.89, 127.0.0.1, 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
# SECURITY NOTE: Listening on all interfaces. Make sure your firewall is
# configured correctly
inet_interfaces = all
smtp_sasl_auth_enable = yes
smtpd_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtpd_sasl_security_options = noanonymous
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $myhostname
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions =
#Following three lines Very imp set as it is or see maillog for error
permit_sasl_authenticated,
permit_mynetworks,
check_relay_domains
default_destination_concurrency_limit = 4
smtpd_enforce_tls = no
smtpd_tls_loglevel = 1
smtpd_use_tls = no
soft_bounce = yes
bounce_template_file = /etc/postfix/bounce.cf
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail
html_directory = no
setgid_group = postdrop
command_directory = /usr/sbin
manpage_directory = /usr/local/man
daemon_directory = /usr/libexec/postfix
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
queue_directory = /var/spool/postfix
mail_owner = postfix
----------------------------------------------------------------------
* Create file /etc/postfix/sasl_passwd host username:passwd
cat /etc/postfix/sasl_passwd
202.78.56.89 shrii:shrii
* Very Imp: Make sure user "shrii" is available on your server. if not you have to create it
with useradd do add same password which you have given to sasl file.
then
chmod 600 /etc/postfix/sasl_passwd
[root@localhost postfix]# ll /etc/postfix/sasl_passwd
-rw------- 1 root root 38 Jul 28 12:54 /etc/postfix/sasl_passwd
Imp stapes:
postmap hash:/etc/postfix/sasl_passwd
restart services :
[root@localhost postfix]# /etc/init.d/saslauthd restart
Stopping saslauthd: [ OK ]
Starting saslauthd: [ OK ]
[root@localhost postfix]# /etc/init.d/postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]
* If issue is :
[root@d]# testsaslauthd -u gimpif -p fbetter
0: NO "authentication failed"
* Do
[root@d] yum install imapd imap dovecot cyrus-imapd cyrus-imapd-perl cyrus-imapd-utils db4-utils libsysfs lm_sensors net-snmp-libs perl cyrus-sasl-plain
yum install courier-imap
Fixed.
testsaslauthd -umail -ppasswd
0: OK "Success."
Let us check mails.
Test Mail from server:
echo "hi" | mail -s " test from local" youremail@domain.com
----------------------------------------------------------------------------------------------------
yum install postfix
* then change default main.cnf to main.cnf.Bak, your config file as follows: /etc/postfix/main.cf
---------------------------------------------------------------------------
myhostname = mail.example.com
mydomain = mail.example.com
myorigin = $mydomain
smtpd_banner = $myhostname ESMTP $mail_name
biff = no
append_dot_mydomain = yes
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = localdomain, localhost, localhost.localdomain, localhost.$mydomain, $mydomain
mynetworks = 202.78.56.89, 127.0.0.1, 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
# SECURITY NOTE: Listening on all interfaces. Make sure your firewall is
# configured correctly
inet_interfaces = all
smtp_sasl_auth_enable = yes
smtpd_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtpd_sasl_security_options = noanonymous
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $myhostname
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions =
#Following three lines Very imp set as it is or see maillog for error
permit_sasl_authenticated,
permit_mynetworks,
check_relay_domains
default_destination_concurrency_limit = 4
smtpd_enforce_tls = no
smtpd_tls_loglevel = 1
smtpd_use_tls = no
soft_bounce = yes
bounce_template_file = /etc/postfix/bounce.cf
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail
html_directory = no
setgid_group = postdrop
command_directory = /usr/sbin
manpage_directory = /usr/local/man
daemon_directory = /usr/libexec/postfix
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
queue_directory = /var/spool/postfix
mail_owner = postfix
----------------------------------------------------------------------
* Create file /etc/postfix/sasl_passwd host username:passwd
cat /etc/postfix/sasl_passwd
202.78.56.89 shrii:shrii
* Very Imp: Make sure user "shrii" is available on your server. if not you have to create it
with useradd do add same password which you have given to sasl file.
then
chmod 600 /etc/postfix/sasl_passwd
[root@localhost postfix]# ll /etc/postfix/sasl_passwd
-rw------- 1 root root 38 Jul 28 12:54 /etc/postfix/sasl_passwd
Imp stapes:
postmap hash:/etc/postfix/sasl_passwd
restart services :
[root@localhost postfix]# /etc/init.d/saslauthd restart
Stopping saslauthd: [ OK ]
Starting saslauthd: [ OK ]
[root@localhost postfix]# /etc/init.d/postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]
* If issue is :
[root@d]# testsaslauthd -u gimpif -p fbetter
0: NO "authentication failed"
* Do
[root@d] yum install imapd imap dovecot cyrus-imapd cyrus-imapd-perl cyrus-imapd-utils db4-utils libsysfs lm_sensors net-snmp-libs perl cyrus-sasl-plain
yum install courier-imap
Fixed.
testsaslauthd -umail -ppasswd
0: OK "Success."
Let us check mails.
Test Mail from server:
echo "hi" | mail -s " test from local" youremail@domain.com