954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

socket.error: (10054, 'Connection reset by peer')

#!/usr/bin/python

import smtplib

sender = 'from@fromdomain.com'
receivers = ['to@todomain.com']

message = """From: From Person <from@fromdomain.com>
To: To Person <to@todomain.com>
Subject: SMTP e-mail test

This is a test e-mail message.
"""

try:
   smtpObj = smtplib.SMTP('smtp.gmail.com')
   smtpObj.sendmail(sender, receivers, message)
   print "Successfully sent email"
except smtplib.SMTPException:
   print "Error: unable to send email"

I get the following error when I try to run the script.

Traceback (most recent call last):
File "", line 244, in run_nodebug
File "C:\Python Rules\scripts\module4.py", line 16, in ?
smtpObj = smtplib.SMTP('smtp.gmail.com')
File "C:\Python23\Lib\smtplib.py", line 240, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python23\Lib\smtplib.py", line 303, in connect
(code, msg) = self.getreply()
File "C:\Python23\Lib\smtplib.py", line 344, in getreply
line = self.file.readline()
File "C:\Python23\Lib\socket.py", line 338, in readline
data = self._sock.recv(self._rbufsize)
socket.error: (10054, 'Connection reset by peer')

sravanthi89
Newbie Poster
4 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

Did you read my code snippet of sending gmail? Compare it with yours, it works.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

I haven't read your code snippet. Could you direct me to the link or post the code here??

cheers
sravanthi

sravanthi89
Newbie Poster
4 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

Quickest you find it by clicking my user name and clicking the code snippet link.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: