I have a problem involving sending out email using a python script. My python script works fine when configured for another mailserver I own, but when I use my dreamhost mail server I get weird behavior. For dreamhost, it sends the first time I try, but then every attempt after that it says socket.error: (104, 'Connection reset by peer'). After waiting 24 hours, again I was able to send a message, and then all attempts after that one had the same error socket.error: (104, 'Connection reset by peer').
Any hints would be helpful. Dreamhost support tells me this is a script problem and they can't help me.
===== SCRIPT =====
from email.MIMEMultipart import MIMEMultipart
from email.Utils import formatdate
from email.MIMEText import MIMEText
msg = MIMEMultipart()
msg['From'] = fr
msg['To'] = to
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = 'subject'
smtp = smtplib.SMTP()