Setting up Sendmail on CentOS/RHEL 6.3

This article will guide you through the installation and configuration steps for Sendmail on CentOS/RHEL 6.3

1) About

The Sendmail program is a very widely used Mail Transport Agent (MTA). MTAs send mail from one machine to another. Sendmail is not a client program, which you use to read your email. Sendmail is a behind-the-scenes program which actually moves your email over networks or the Internet to where you want it to go.

How Sendmail Works

Incoming Mail
Usually each user in your home has a regular Linux account on your mail server. Mail sent to each of these users ( eventually arrives at your mail server and sendmail then processes it and deposits it in the mailbox file of the user’s Linux account. Mail isn’t actually sent directly to the user’s PC. Users retrieve their mail from the mail server using client software, such as Microsoft’s Outlook or Outlook Express, that supports either the POP or IMAP mail retrieval protocols.
Linux users logged into the mail server can read their mail directly using a text-based client, such as mail, or a GUI client, such as Evolution. Linux workstation users can use the same programs to access their mail remotely.

Outgoing Mail
The process is different when sending mail via the mail server. PC and Linux workstation users configure their e-mail software to make the mail server their outbound SMTP mail server.
If the mail is destined for a local user in the “” domain, then sendmail places the message in that person’s mailbox so that they can retrieve it using one of the methods above.
If the mail is being sent to another domain, sendmail first uses DNS to get the MX record for the other domain. It then attempts to relay the mail to the appropriate destination mail server using the Simple Mail Transport Protocol (SMTP). One of the main advantages of mail relaying is that when a PC user A sends mail to user B on the Internet, the PC of user A can delegate the SMTP processing to the mail server.

2) Prerequisite
Most important tasks in setting up DNS for your domain ( is to use the MX record in the configuration zone file to state the hostname of the server that will handle the mail for the domain.
Install the following dependent package:

 # yum install m4 telnet mailx

3) Installation
3.1) Check if sendmail is installed or not:

 # rpm –qa | grep sendmail

3.2) If it is not installed, then install the sendmail package using following command:

 # yum install sendmail sendmail-cf

4) Configuration
4.1) By default sendmail configuration files are located at /etc/mail.
4.2) By default sendmail listen on local interface i.e, check using this command:

 # ps -ef | grep -v grep | grep -i sendmail root 3595 1 0 00:20 ? 00:00:00 sendmail: accepting connections smmsp 3604 1 0 00:20 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue # netstat -an | grep :25 | grep tcp tcp 0 0* LISTEN

4.3) To configure the sendmail to listen to all interface at the host, just comment the following line in “”:

 # vi /etc/mail/ From: DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')dnl To dnl DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')dnl

4.4) Now we need to build the “” file using m4 macro:

 # m4 /etc/mail/ > /etc/mail/

4.5) Restart Sendmail Service:

 # service sendmail restart

4.6) Check using this command:

 # netstat -an | grep :25 | grep tcp tcp 0 0* LISTEN

4.7) Adding your domain entry in “/etc/mail/local-host-names” file:
Add all domains for which you will accept mail; there should be one domain per line.
For example, if this mail server was to accept mail for the domains “”,”

 # vi /etc/mail/local-host-names

4.8) Restart the service of sendmail and make a entry for it to start at boot time:

 # service sendmail restart # chkconfig sendmail on

5) Validation and Testing
5.1) Create two test user for testing purpose (that will send and receive mail):

 # useradd testuser1 # useradd testuser2

5.2) Login as one of the user (say testuser1) and try to send mail using mail command:

 $ mail -s "Test mail from testuser1" testuser2 Hello this is the test mail . EOT

5.3) Now we need to check the Maillog “/var/log/maillog” in case of any issue

 # tail /var/log/maillog Aug 19 01:07:58 server001 sendmail[4019]: r7IJalr6004019:, size=37, class=0, nrcpts=1, msgid=, proto=SMTP, daemon=MTA, relay=localhost [] Aug 19 01:07:58 server001 sendmail[4022]: r7IJalr6004019:, (502/503), delay=00:00:39, xdelay=00:00:00, mailer=local, pri=30438, dsn=2.0.0, stat=Sent

5.4) Once mail has been delivered successfully now we need to check if mail is delivered to user (testuser2) mailbox or not
We would see something like the following output:

 $ mail N 1 Mon Aug 19 01:07 13/503 "Sendmail Test"

6) Firewall Rule:

6.1) Firewall port that needs to be open for sendmail daemon machine:

 # iptables -A INPUT -p tcp -m tcp ​--destination-port ​25 -j ACCEPT

6.2) Save the Iptables rules and restart it.

 service iptables save service iptables restart

Congratulation you have successfully setup MTA service using Sendmail, now is the time to configure Dovecot service to fetch mail using your favourite MUA (Mail User Agent) like MS Outlook, Thunderbird etc.


Posted in Uncategorized. Leave a Comment »

SQL Transpose of WordPress meta tables (key-value pairs)

Here is sample demo sql:

select * from (

SELECT m.user_id,
MAX(CASE WHEN m.meta_key = ‘first_name’ THEN m.meta_value ELSE NULL END) AS first_name,
MAX(CASE WHEN m.meta_key = ‘last_name’ THEN m.meta_value ELSE NULL END) AS last_name
FROM wp_usermeta m
GROUP BY m.user_id

) as s where first_name = ‘John’


Posted in Uncategorized. Leave a Comment »

Warid 4G LTE v/s PTCL Evo 3G

I found a chance to test both internet services using USB wingle devices. I first checked the signals and then tried on it. I made these tests in morning around 6.30am (Location: gulshan-e-iqbal, block 4, Date: 19th June 2015)

1) Warid 4G LTE
2) PTCL Evo 3G
I hate to admit, but PTCL EVO 3G was far better than what 4G LTE is capable of. Perhaps Warid has limited the performance due to their SLAs. The uploading speed of LTE is better but most of us are concerned on downloading speed.
Posted in Uncategorized. 2 Comments »

JQueryUI with Metro Theme

A search for Metro theme based on Jquer UI actually resulted in this post. JQUIT builder seems to be promising option but it’s now unmaintained and all builder links are removed. I further searched and found a much similar cusotmization of jQuery UI to match like Metro.

Here is the Jquery UI theme link after my little modification.


Download: Metro Light | Metro Dark

You can replace metro blue shade with other high/low contrast colors of windows 8 (purple, orange, green etc).

Here are the links for color set.

Have fun.

Posted in Uncategorized. Leave a Comment »

“Go To File” Feature/Plugin for Notepad++

The plugin that I found that has this feature is called Open File in Solution

Here’s a link to download the plugin and documentation:


  1. Install the above 4 plugins from here (I just downloaded them manually and dropped them in my plugins directory).
  2. Start Notepad++.  Select Plugins -> SolutionHubUI -> SolutionHubUI Show from the menu
  3. Here you define your solution or project.  Click “New Solution” and enter a Name.  Then click the “Path” icon and select it’s root folder.  Tick the “Recursive” and “Monitored” checkboxes to ensure the files within this folder are indexed, and you can optionally add Exclusions file filter to skip any files you don’t want indexed (like “jpg gif png” files).
  4. Click “Save Solution”, then double-click the “Connections” value in the table at the top and enter “ofis” as a connection for your new solution.  This will associate your solution with “Open File In Solution” to make this feature work.  Then click “Save Connections”.  (You can define multiple solutions/projects, but only one can have the “ofis” association at one time.  This provides a crude way of switching between solutions/projects)
  5. Now test your Solution by going to the menu and selecting Plugins -> Open File In Solution -> OFIS – Show.  You should see a dialog that allows you to search all the files in your solution.
  6. Now we’ll define some keyboard shortcuts.  Go to Settings -> Shortcut Mapper… and choose the “Plugin commands” tab.
  7. Find the entry called “OFIS – Show” and give it a shortcut.  I personally use Ctrl+Shift+R as that’s what I’m used to from Eclipse, however this is used by the out-of-the-box Macro Record.  So I have to disable this shortcut manually under “Main Menu” tab.  (Unfortunately Notepad++ doesn’t warn you if there’s a clash).
  8. Next, find the entry under the “Plugin commands” tab called “ST – Open document” and give this another short-cut.  This is how you open files that are referenced in your source (like F3 in Eclipse).  I personally map this to Ctrl-Shift-=.
  9. That’s it!


​One more tip. If you like the RubyBlue colour theme, grab the enhanced version that includes additional language support (like java). It’s available from:

Posted in Uncategorized. Leave a Comment »

5 Google Products That Failed and What Startups Can Learn From It

Visit following link. Saved just to bookmark on blog.

Posted in Uncategorized. Leave a Comment »

I’ve inherited 200K lines of spaghetti code — what now?

​I came across a very good question (as mentioned in title of post) and fantastic answer. This is common problem for senior developers / project leads who just landed on some previously coded project. I’ve seen such scenes quite a lot time and all ends in frustration and left unresolved.

Posting on blog for reference. Actual question / answers are here:

Top answer summary:

Executive Summary for the Impatient

  • Define a rigid project structure, with:
    • project templates,
    • coding conventions,
    • familiar build systems,
    • and sets of usage guidelines for your infrastructure and tools.
  • Install a good SCM and make sure they know how to use it.
  • Point them to good IDEs for their technology, and make sure they know how to use them.
  • Implement code quality checkers and automatic reporting in the build system.
  • Couple the build system to continuous integration and continuous inspection systems.
  • With the help of the above, identify code quality "hotspots" and refactor.

Now for the long version… Caution, brace yourselves!

Read here:

Posted in Uncategorized. Leave a Comment »