Smtplib and exceptions- why it does NOT work

Kragen Sitaker kragen at pobox.com
Mon May 20 21:40:47 EDT 2002


"A" <printers at sendme.cz> writes:
> class SMTPM:
>     
>     def sendMail(self):
>         import smtplib
>         self.s11 = smtplib.SMTP('smtp.sendme.cz')
>         
>         try: 
>             Response=self.s11.sendmail('a at NonExistingDomain.com',"printers at sendme.cz","TEST")
>         except(smtplib.SMTPRecipientsRefused,smtplib.SMTPSenderRefused ):
>             print "Response ",Response
> A=SMTPM()
> A.sendMail()
> 
> But it does not work.
> Can anybody please explain to me why?

I think you want:
   except(smtplib.SMTPRecipientsRefused,smtplib.SMTPSenderRefused ), err:
   print "Response ", err




More information about the Python-list mailing list