sending mail from gmail account - Python
Question: could someone kindly tell me, what's wrong with the code below? TIA :)))

    
    
    import smtplib
    if raw_input("if you want to send a message from a gmail account, type yes: ") == 'yes':
        try:      
            sender = raw_input("from:\n")
            senders_pwd = raw_input("password:\n")
            recipient = raw_input("to:\n")
            print 'ok, now compile your message:'
            subject = raw_input("subject:\n")
            body = raw_input("your message:\n")
            message = "subject: %s\n%s" %(subject,body)
    
            server = smtplib.SMTP("smtp.gmail.com",587)
            server.ehlo()
            server.starttls()
            server.ehlo()
            print "ok, I've sent your email"
        except:
            print 'failed to send'
    


Answer: You need to call the sendmail() function. Add something like these three lines
after the last server.ehlo():

    
    
    server.login(sender, senders_pwd)
    server.sendmail(sender, recipient, message)
    server.close()
    

