Hey Stefan,<br>
<br>
Thanks for your response. <br>
My script is similar to yours, but as you've pointed that it could be
temporary. I've been re-trying to connect and send email but in vain.<br>
Here's the snippet of my code. Can you debug and help me what could really have gone wrong.<br>
____________________________________________________________________<br>
import smtplib<br>
import base64<br>
<br>
smtpserver = 'smtp.gmail.com'<br>
AUTHREQUIRED = 0 # if you need to use SMTP AUTH set to 1<br>
smtpuser = 'user@gmail.com'  # for SMTP AUTH, set SMTP username here<br>
smtppass = '*****'  # for SMTP AUTH, set SMTP password here<br>
<br>
RECIPIENTS = ['someuser@gmail.com']<br>
SENDER = 'someuser@gmail.com'<br>
mssg = open('mssg.txt', 'r').read() # I am reading from this file on the same directory<br>
<br>
session = smtplib.SMTP(smtpserver,'465')<br>
session.ehlo()<br>
#session.esmtp_features["auth"] = "LOGIN PLAIN"<br>
session.connect(smtpserver,'465')<br>
session.ehlo()<br>
session.starttls()<br>
session.set_debuglevel(1)<br>
session.helo()<br>
<br>
if AUTHREQUIRED:<br>
    try:<br>
            session.login(smtpuser, smtppass)<br>
    <br>
    except SMTPAuthenticationError, e:<br>
    # if login fails, try again using a manual plain login method<br>
            smtp.docmd("AUTH LOGIN", base64.b64encode( smtpuser ))<br>
            smtp.docmd(base64.b64encode( smtppass ), "")<br>
smtpresult = session.sendmail(SENDER, RECIPIENTS, mssg)<br>
if smtpresult:<br>
    errstr = ""<br>
    for recip in smtpresult.keys():<br>
        errstr = """Could not delivery mail to: %s<br>
<br>
Server said: %s<br>
%s<br>
<br>
%s""" % (recip, smtpresult[recip][0], smtpresult[recip][1], errstr)<br>
    raise smtplib.SMTPException, errstr<br>
____________________________________________________<br>This is the Stack Trace I got when I ran the above script after a very long time(&gt;15min)<br><br>Traceback (most recent call last):<br>  File "C:\Python26\Mail.py", line 13, in &lt;module&gt;<br>    session = smtplib.SMTP(smtpserver,'465')<br>  File "C:\Python26\lib\smtplib.py", line 239, in __init__<br>    (code, msg) = self.connect(host, port)<br>  File "C:\Python26\lib\smtplib.py", line 296, in connect<br>    (code, msg) = self.getreply()<br>  File "C:\Python26\lib\smtplib.py", line 340, in getreply<br>    raise SMTPServerDisconnected("Connection unexpectedly closed")<br>smtplib.SMTPServerDisconnected: Connection unexpectedly closed<br><br>Tool completed with exit code 1<br><br>______________________________________________________________________<br>
Thanks<br>
Avinash<br><br><blockquote><br>---------- Original message ----------<br>From:Stefan Lesicnik&lt; stefan@lsd.co.za &gt;<br>Date: 11 Mar 09 12:12:45<br>Subject:  Re: [Tutor] How to send an email using Python<br>To: Senthil Kumaran <orsenthil@gmail.com><br><br></orsenthil@gmail.com></blockquote>