SMTP command stuck in cmd prompt

Keywords: python

Question: 

I have installed Python 2.7 in widows 7. 
I am trying a basic smtp python program to automatically send mail through python script. But when I am running the script through cmd prompt, it is just stuck indefinitely.

*# Python code to illustrate Sending mail
# to multiple users
# from your Gmail account
import smtplib

# list of email_id to send the mail 
li = ["ishank4@gmail.com"] 

for i in range(len(li)): 
    s = smtplib.SMTP('smtp.gmail.com', 587) 
    s.starttls() 
    s.login("mymailid@gmail.com", "mypassword") 
    message = "Message_you_need_`enter code here`to_send"
    s.sendmail("sender_email_id", li[i], message) 
    s.quit()*

Answers: