Password expiry notification script
I'm just going to comment on these three lines:

SendMail = "echo '" + MsgBody % (uid,ExpireIn,d2) + "' \
          mail -s " + '"' + Subject + '"' + ' ' + \
          uid + '@' + EmailDomain 
#os.system(SendMail)
print SendMail



This doesn't work! You've commented out the line that sends the e-mail. Now, I understand that you did this so that you can test the script without spamming your users with these messages, and that you intend to uncomment the line when you deploy the script. But this isn't the best approach.

The first problem is that the need to test the script will come up again after you deploy it — you'll need to revise the text of the messages or change some other aspect the way it works, and then you'll want to test it again. So it would be worth your while to build in a permanent testing mechanism that's better than commenting out a line.

The second problem is that just printing the mail command doesn't actually constitute a test. You have to read the output in order to check that it's correct, and you could easily miss a problem.

What I suggest is that you have a setting that can be turned on and off to indicate whether the script is in testing or deployment:

deployed = False           # Is script deployed?
test_uid = 'rahul.patil'   # Send e-mail to this user if not deployed.


and that you send the e-mail to the test user when testing:

if not deployed:
    uid = test_uid
SendMail = "echo '" + MsgBody % (uid,ExpireIn,d2) + "' \
          mail -s " + '"' + Subject + '"' + ' ' + \
          uid + '@' + EmailDomain 
os.system(SendMail)


Ideally you would provide a way to set the deployed flag (and the test_uid) through the script's command-line interface — see the argparse module for one approach to doing this.
When you run a command using os.system, the command gets interpreted by the shell. This is risky, because the shell has complicated quoting and evaluation rules that you may not understand. For example, suppose that you edited MsgBody like this:

MsgBody = """
Dear %s,
     Your password will expire in %s day(s). We're sorry for the
inconvenience, but we need you to change your password by %s.
"""


Looks good, right? But if you actually try this, you'll find that the call to os.system fails with an error like this:

sh: line 3: inconvenience,: command not found
sh: -c: line 4: unexpected EOF while looking for matching `''
sh: -c: line 5: syntax error: unexpected end of file


That's because the single quote in We're was interpreted by the shell as terminating the argument to echo.

In order to avoid problems like this (where data gets wrongly interpreted as code by the shell), you should avoid passing the arguments to the shell. Instead of os.system, you should use the functions in the subprocess module. For example, like this:

import subprocess

p = subprocess.Popen(['mail', '-s', Subject, uid + '@' + EmailDomain],
                     stdin=subprocess.PIPE)
p.communicate(MsgBody % (uid, ExpireIn, d2))