[Tutor] email-sending..
jan.n
jndomain at yahoo.com
Sat Jan 28 06:17:27 CET 2006
Hello,
i am trying to send emails through a python script , but it complains that
socket error 10061 conection refused..
any help with this would be great...
import smtplib
smtpserver = 'mailserver'
AUTHREQUIRED = 1 # if you need to use SMTP AUTH set to 1
smtpuser = '#####' # for SMTP AUTH, set SMTP username here
smtppass = '#####' # for SMTP AUTH, set SMTP password here
flname = 'c:\\Python24\\mssg.txt'
#c:\\tst.txt
RECIPIENTS = ['someaddress at yahoo.com']
SENDER = 'someaddress at yahoo.co.in'
mssg = open(flname , 'r').read()
session = smtplib.SMTP(smtpserver)
if AUTHREQUIRED:
session.login(smtpuser, smtppass)
smtpresult = session.sendmail(SENDER, RECIPIENTS, mssg)
if smtpresult:
errstr = ""
for recip in smtpresult.keys():
errstr = """Could not delivery mail to: %s
Server said: %s
%s
%s""" % (recip, smtpresult[recip][0], smtpresult[recip][1], errstr)
raise smtplib.SMTPException, errstr
---------------------------------
Find your next car at Yahoo! Canada Autos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060128/c8e90f07/attachment.html
More information about the Tutor
mailing list