Sunday, March 16, 2014

How to install and configure sendmail server in Linux?


The sendmail can be configured from  files in /etc/mail and a directory of configuration files in /usr/share/sendmail-cf. There are two basic configuration files:
  1. sendmail.cf The main sendmail configuration file.
  2. sendmail.mc A macro that's easier to edit, which can be used to generate a new sendmail.cf file.
In this example you can use two systems linux server , and linux clients.
  • A linux server with ip address 192.168.0.100 and hostname Server
  • A linux client with ip address 192.168.0.10 and hostname Client1
  • A Configured DNS server on Linux server and remember to set MX record
  • Updated /etc/hosts file on both linux system
  • Running portmap and xinetd services
  • Firewall (iptable) should be off for port 25 on server


Configure sendmail server

sendmail and m4 rpm are required to configure sendmail server

 sendmail rpm

Sendmail program reads the /etc/mail/sendmail.cf. Change the /etc/mail/sendmail.mc file. When Sendmail is started or restarted with the service sendmail restart command a new sendmail.cf file is automatically generated if sendmail.mc has been modified.

open /etc/mail/sendmail.mc for editing
vi /etc/mail/sendmail.conf


The following line limits sendmail access to connect local host only [line no 116]
sendmail.mc

 You can allow other computers to use your sendmail server by commenting out this line.

In the sendmail.mc file , lines that begin with dnl, which stands for delete to new line, are considered comments. Some lines end with dnl, but lines ending in dnl are not comments

comment this line with dnl keyword followed by # sign
sendmail.mc
save this file with :ZZ and exit.

Now generate new sendmail.cf file by using m4 command as shown here
m4


Run chkconfig so that sendmail server should start automatically after restart the server and start the sendmail service

 service sendmail restart
 

Testing of your sendmail server


  Create user abc
useradd abc
Add password
passwd abc

echo "BODY" | mail -s "Subject" abc
mail sent to abc user.

How to find which process is eating RAM memory in Linux Operting System?

ps aux | awk '$6 > 0{print $3, $4, $5, $6}'
or

ps aux | awk '{print $2, $4, $11}' | sort -k2r | head -n 20