Here is a program that I wrote using one of
the python.org's examples at 12.2.13 (first example
listed):
# Import smtplib for the actual sending
function
import smtplib # Import the email modules we'll need
from email.MIMEText import MIMEText # Open a plain text file for reading. For
this example, assume that
# the text file contains only ASCII characters. fp = open(r'C:\Documents and Settings\User\Desktop\\text3.txt') # Create a text/plain message msg = MIMEText(fp.read()) fp.close() # me == the sender's email address
# you == the recipient's email address msg['Subject'] = 'The contents of %s' % 'C:\Documents and Settings\User\Desktop\\text3.txt' msg['From'] = '[EMAIL PROTECTED]' msg['To'] = '[EMAIL PROTECTED]' # Send the message via our own SMTP server, but
don't include the
# envelope header. s = smtplib.SMTP() s.connect() __init__(self, host='', port=0, local_hostname=None) s.sendmail('[EMAIL PROTECTED]', ['[EMAIL PROTECTED]'], msg.as_string()) s.close() And this is what I get when I run the
program using IDLE:
Traceback (most recent call last):
File "C:\Documents and Settings\User\Desktop\textsender.py", line 23, in ? s.connect() File "C:\Python24\lib\smtplib.py", line 307, in connect (code, msg) = self.getreply() File "C:\Python24\lib\smtplib.py", line 348, in getreply line = self.file.readline() File "C:\Python24\lib\socket.py", line 340, in readline data = "">error: (10054, 'Connection reset by peer') Anybody have any
suggestions?
Grady Henry
|
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor