Hi All,
I am a total newbe to python. I am using some already available code to send email from commandline using my Gmail account.

For the piece of code
smtp = smtplib.SMTP('smtp.gmail.com', 587)

I get a error
################
Traceback (most recent call last):
File "Mail.py", line 44, in <module>
smtp.connect('smtp.gmail.com', 587)
File "e:\Python30\lib\smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "e:\Python30\lib\smtplib.py", line 273, in _get_socket
return socket.create_connection((host, port), timeout)
File "E:\Python30\lib\socket.py", line 303, in create_connection
raise error(msg)
socket.error: [Errno 10060] A connection attempt failed because the connected pa
rty did not properly respond after a period of time, or established connection f
ailed because connected host has failed to respond
###########

The same code work fine when I running the script from Home. When I try from my office, I get the problem. If I replace the smtp server with my office smtp server (with port 25), I have no problem.

Also I checked that the port is open (Using netstat) and moreover I dont have a FireWall enabled.

Please help me debug.

Try and see if you can ping that server/port from your office. It seems like it's getting blocked.

Try and see if you can ping that server/port from your office. It seems like it's getting blocked.

I tried doing "telnet smtp.gmail.com 587" and i get message
"Cannot connect to host on port 587"
I even added the port 587 to the windows firewall.
Currently We have Symantic Antivirus and Web root Spy sweeper.

Any help is appreciated.
Currently I have modified the script to send mail using my office SMTP and using forwarding option in Gmail as a indirect way

It would seem that your network is blocking the site.

Are you able to access it via web browser?

It would seem that your network is blocking the site.

Are you able to access it via web browser?

Yep, I can access my gmail from web browser. I even have gtalk also installed on my machine. As such we do not have any kind of restriction on installing any software or acessingg any website.
I have entire admin rights on my machine in office.

But still I face this problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.