- #1
dacruick
- 1,042
- 1
Hello ladies and gentlemen,
I have grabbed a code for emailing using python. This isn't my end goal, but I think its a logical place to start and get used to the smtp library. here is the code
I'm getting a server connection error called a socket error. on the line "server = smtplib.SMTP('localhost')"
It is telling me that my connection is being reset by a peer. Does anyone know what that means and what I can do to get rid of that error?
I have grabbed a code for emailing using python. This isn't my end goal, but I think its a logical place to start and get used to the smtp library. here is the code
Code:
import smtplib
def prompt(prompt):
return raw_input(prompt).strip()
fromaddr = prompt("From: ")
toaddrs = prompt("To: ").split()
print "Enter message, end with ^D (Unix) or ^Z (Windows):"
# Add the From: and To: headers at the start!
msg = ("From: %s\r\nTo: %s\r\n\r\n"
% (fromaddr, ", ".join(toaddrs)))
while 1:
try:
line = raw_input()
except EOFError:
break
if not line:
break
msg = msg + line
print "Message length is " + repr(len(msg))
server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
I'm getting a server connection error called a socket error. on the line "server = smtplib.SMTP('localhost')"
It is telling me that my connection is being reset by a peer. Does anyone know what that means and what I can do to get rid of that error?