Errno 10013 An attempt was made to access socket in a way forbidden - python 2.7

0

I'm trying to create a script that sends a simple email through gmail with python 2.7 but at the time of executing the code I get the following error:

  

Connection to Gmail failed   [Errno 10013] An attempt was made to access to socket in a way forbidden by its access permissions

     

Warning (from warnings module):     File "C: \ Python27 \ lib \ getpass.py", line 92       return fallback_getpass (prompt, stream)   GetPassWarning: Can not control echo on the terminal.   Warning: Password input may be echoed.   Press ENTER to continue ..

What is the reason?

my code is:

import smtplib, socket, sys, getpass

def main():
    print

    try:
        smtpserver = smtplib.SMTP("smtp.gmail.com", 587)
        smtpserver.ehlo()
        smtpserver.starttls()
        smtpserver.ehlo()
        print "Connection to Gmail was successful"
        print "Connected to gmail" + "\n"




    except (socket.gaierror,socket.error,socket.herror,smtplib.SMTPException),e:
        print "Connection to Gmail failed"
        print e 
        getpass.getpass("Press ENTER to continue..")
        sys.exit(1)



    print "\n"
    raw_input("pause program")

main()
    
asked by Erick Finn 18.08.2017 в 18:32
source

0 answers