Hi all

I need to send mail in my turbogears apps and i would like to not stop
the current process during making this kind of stuff (for example :
some time the smtp server may fails and i dont want to crash my apps
with that)...

I have made a Table where i put all the pending mail to send and i
would like to start my sendPendingMail() function inside a new tread
or process, i have tried with something like this but it doesnt work :

class sendPendingMailThread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):
        import smtplib
        from email.MIMEText import MIMEText
        import time

        try:
            for m in PendingMail.select():
                mail = MIMEText(m.message.encode('utf-8'), 'plain',
'UTF-8')
                mail['From'] = '[EMAIL PROTECTED]'
                mail['Subject'] = m.subject.encode('utf-8')
                mail['To'] = m.dest
                smtp = smtplib.SMTP()
                smtp.connect('mail.log.intra.laposte.fr')
                smtp.login('[EMAIL PROTECTED]', 'pmrh114')
                smtp.sendmail('[EMAIL PROTECTED]', [m.dest],
mail.as_string())
                smtp.close()
                m.delete()
        except:
            True


any ideas ??

Cheers
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to