Python won't print after smtplib.SMTP
<p>I was trying to write a python sendmail class, I like to print sent mail info, but after smtplib.SMTP it won't print anything, even an error, here is my code: </p>

<p>main.py:</p>

<pre><code>import MailServer
from Mailler import Mailler

mail_server = MailServer.Server()
mailler = Mailler( mail_server )
mailler.sender = 'test@gmail.com'
mailler.receiver = 'test@ymail.com'
mailler.subject = 'test'
mailler.send_text( 'test' )
</code></pre>

<p>Mailler.py:</p>

<pre><code>import email
import smtplib

class Mailler():

    sender = ''
    receiver = ''

    def __init__( self, target_server ):
        self.target_server = target_server
        print 'host:' + target_server.host + ' port:' + str( target_server.port )
        self.server = smtplib.SMTP( target_server.host, target_server.port )
        self.server.set_debuglevel( 1 )
        print 'test 2'

    def __enter__( self ):
        return self

    def send_text( self, subject, message ):
        mail = email.mime.text.MIMEText( message )
        mail[ 'Subject' ] = subject
        mail[ 'From' ] = self.sender
        mail[ 'To' ] = self.receiver

        self.server.sendmail( self.sender, [self.receiver], mail.as_string )
        print 'Mail sent:' + subject + ' sender:' + self.sender + ' receiver:' + self.receiver

    def __exit__( self, type, value, traceback ):
        self.server.quit()
</code></pre>

<p>the output:</p>

<pre><code>host:127.0.0.1 port:22223
</code></pre>
