@pradeep, thatnks for this info.

I had written something similar but had a problem when my manager asked me a question that what if sendmail itself is not installed on a server. He asked me to write something which is very basic and works with basic perl modules.

So my question to you. What if sendmail is not installed?