Tuesday, July 28, 2009

Postfix SMTP installation on CentOs/Linux

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 =,,
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
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 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.


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

testsaslauthd -umail -ppasswd
0: OK "Success."

Let us check mails.

Test Mail from server:
echo "hi" | mail -s " test from local" youremail@domain.com

ezcrypto segmentation fault error (Rails 2.3.2)

There is dependency of openssl version for ezcrypto gem, fix as follows.
gem install ezcrypto

gem list
*** LOCAL GEMS ***

ezcrypto (0.7.2)

*Check openssh Version.!

rpm -q openssl-devel openssl

* if found openssl-devel-0.9.8b-10.el5 and openssl-0.9.8b-10.el5. Please remove from repository.
Using this command.

rpm -e openssl-devel-0.9.8b-10.el5 openssl-0.9.8b-10.el5

*If not present install this package.
rpm -ivh --force /var/cache/yum/base/packages/openssl-0.9.8e-7.el5.i386.rpm
rpm -ivh --force /var/cache/yum/base/packages/openssl-devel-0.9.8e-7.el5.i386.rpm

* if not found in package in /var/cache/yum/base/packages/ then download from
http://mirror.centos.org/centos-5/5.3/os/i386/CentOS/ and copy in /var/cache/yum/base/packages/
and install again.

* check the package and version.

rpm -q openssl-devel openssl

Thanks- Now Its Fixed.