0
#!/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 "<string>", 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')

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by pyTony
0

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

cheers
sravanthi

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.