Python论坛  - 讨论区

标题:[python-chinese] smtplib级联异常

2007年12月12日 星期三 08:55

赵威 zhaowei在pythonid.com
星期三 十二月 12 08:55:00 HKT 2007

Romit,您好!

	又是遇到反垃圾邮件了...
异常可以捕获到的,应该是你捕获的地方不对

======= 2007-12-09 12:28:52 您在来信中写道:=======

>我为某企业写了一个向该企业员工群发电子邮件的程序,使用的是smtplib。在通
>过smtp协议迭代群发邮件的时候,特别是连续发送超过32份的时候,smtp服务器拒
>绝我发送请求的时候,smtplib通常会抛出一个异常:
>smtplib.SMTPException
>紧跟着是另外一个异常:
>smtplib.SMTPServerDisconnected
>这个异常没办法捕获到,虽然我的程序里有这个异常处理子句。
>我该怎么处理这个异常?
>
>_______________________________________________
>python-chinese
>Post: send python-chinese在lists.python.cn
>Subscribe: send subscribe to python-chinese-request在lists.python.cn
>Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        赵威
        zhaowei在pythonid.com
          2007-12-12


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月12日 星期三 09:07

limodou limodou在gmail.com
星期三 十二月 12 09:07:46 HKT 2007

Bug fix verion.

   1. Remove profile invoke(big mistake)
   2. Fix svn plugin checkout bug

Download:
http://ulipad.googlecode.com/files/ulipad.3.8.1.zip
http://ulipad.googlecode.com/files/ulipad.3.8.1.exe

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月12日 星期三 09:52

Romit m_list在126.com
星期三 十二月 12 09:52:26 HKT 2007

确实是反垃圾邮件的问题,该企业会在月末向员工发送业绩、工资等信息,所以发
送邮件量会比较大,我想在邮件服务器禁止发送后,程序自动等待10分钟后重试,
但是每次SMTP服务器拒绝以后,随后会自动断开连接,你帮忙看一下程序存在什么
问题。
for a in mbl:
           
subject=self.mngCltXML.get_widget('entry8').get_text().encode('gb2312')
           
text=self.mngCltXML.get_widget('textview1').get_buffer().get_text(self.mngCltXML.get_widget('textview1').get_buffer().get_start_iter(),self.mngCltXML.get_widget('textview1').get_buffer().get_end_iter()).encode('gb2312')
            msg=MIMEText(text,_subtype='plain',_charset='GB2312')

            msg['Subject']=subject
            msg['From']=conf['user']
            msg['To']=str(a)+'@sx.133165.com'

            try:
                server=smtplib.SMTP(conf['host'],conf['port'])
                server.set_debuglevel(0)
            except smtplib.SMTPException:
               
cid_except=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
exception class for all exceptions raised by this module.')
               
self.mngCltXML.get_widget('statusbar1').push(cid_except,u'请更换信箱,服
务器拒绝')
                time.sleep(50)
                self.mngCltXML.get_widget('statusbar1').pop(cid_except)
            except smtplib.SMTPServerDisconnected:
               
cid_sdiscn=self.mngCltXML.get_widget('statusbar1').get_context_id('Server
disconnectiod')
               
self.mngCltXML.get_widget('statusbar1').pusb(cid_sdiscn,u'服务器连接中断')
                time.sleep(5)
                self.mngCltXML.get_widget('statusbar1').pop(cid_sdiscn)
            except smtplib.SMTPResponseException:
               
cid_rsp=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
class for all exceptions that include an SMTP error code. These
exceptions are generated in some instances when the SMTP server returns
an error code. The error code is stored in the smtp_code attribute of
the error, and the smtp_error attribute is set to the error message.')
                self.mngCltXML.get_widget('statusbar1').push(cid_rsp,u'
服务器响应错误')
                time.sleep(5)
                self.mngCltXML.get_widget('statusbar1').pop(cid_rsp)
            except smtplib.SMTPSenderRefused:
               
cid_srfus=self.mngCltXML.get_widget('statusbar1').get_context_id('Sender
address refused. In addition to the attributes set by on all
SMTPResponseException exceptions, this sets `sender\' to the string that
the SMTP server refused.')
               
self.mngCltXML.get_widget('statusbar1').push(cid_srfus,u'发件地址被拒绝')
                time.sleep(600)
                self.mngCltXML.get_widget('statusbar1').pop(cid_srfus)
            except smtplib.SMTPRecipientsRefused:
                #如果收件人不存在,直接跳过
                continue
            except smtplib.SMTPDataError:
               
cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
server replied with an unexpected error code (other than a refusal of a
recipient).')
                self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
服务器返回错误')
                time.sleep(5)
                self.mngCltXML.get_widget('statusbar1').pop(cid_data)
            except smtplib.SMTPConnectError:
               
cid_conn=self.mngCltXML.get_widget('statusbar1').get_context_id('Error
occurred during establishment of a connection with the server.')
                self.mngCltXML.get_widget('statusbar1').push(cid_conn,u'
与服务器连接错误,请更换信箱')
                time.sleep(50)
                self.mngCltXML.get_widget('statusbar1').pop(cid_conn)
            except smtplib.SMTPHeloError:
               
cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
server didn\'t reply properly to the "HELO" greeting.')
                self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
服务器未正确相应')
                time.sleep(5)
                self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
           

            try:
                server.login(conf['user'],conf['passwd'])
            except smtplib.SMTPAuthenticationError:
               
cid_auth=self.mngCltXML.get_widget('statusbar1').get_context_id('The
server didn\'t accept the username/password combination.')
                self.mngCltXML.get_widget('statusbar1').push(cid_auth,u'
用户名或者密码错误,请在SMTP 设置输入正确的用户和密码')
                time.sleep(5)
                self.mngCltXML.get_widget('statusbar1').pop(cid_auth)
            except smtplib.SMTPHeloError:
               
cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
server didn\'t reply properly to the "HELO" greeting.')
                self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
服务器未正确相应')
                time.sleep(5)
                self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
            except smtplib.SMTPError:
               
cid_err=self.mngCltXML.get_widget('statusbar1').get_context_id('No
suitable authentication method was found')
                mngCltXML.get_widget('statusbar1').push(cid_err,u'验证方
法不匹配')
                break
                self.mngCltXML.get_widget('statusbar1').pop(cid_err)


            try:
                server.sendmail(conf['user'],
str(a[0])+'@sx.133165.com',msg.as_string())
            except smtplib.SMTPRecipientsRefused:
                #如果收件人不存在,直接跳过
                continue
            except smtplib.SMTPHeloError:
               
cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
server didn\'t reply properly to the "HELO" greeting.')
                self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
服务器未正确相应')
                time.sleep(5)
                self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
            except smtplib.SMTPSenderRefused:
                # 发件地址被拒绝通常是由于发送大量电子邮件爱你导致,所以
休眠一段时间后重复发送
                server.close()
                time.sleep(600)
                server=smtplib.SMTP(conf['host'],conf['port'])
                server.server.login(conf['user'],conf['passwd'])
               
            except smtplib.SMTPDataError:
               
cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
server replied with an unexpected error code (other than a refusal of a
recipient).')
                self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
服务器返回错误')
                time.sleep(5)
                self.mngCltXML.get_widget('statusbar1').pop(cid_data)

            server.quit()


赵威 写道:
> Romit,您好!
>
> 	又是遇到反垃圾邮件了...
> 异常可以捕获到的,应该是你捕获的地方不对
>
> ======= 2007-12-09 12:28:52 您在来信中写道:=======
>
>   
>> 我为某企业写了一个向该企业员工群发电子邮件的程序,使用的是smtplib。在通
>> 过smtp协议迭代群发邮件的时候,特别是连续发送超过32份的时候,smtp服务器拒
>> 绝我发送请求的时候,smtplib通常会抛出一个异常:
>> smtplib.SMTPException
>> 紧跟着是另外一个异常:
>> smtplib.SMTPServerDisconnected
>> 这个异常没办法捕获到,虽然我的程序里有这个异常处理子句。
>> 我该怎么处理这个异常?
>>
>> _______________________________________________
>> python-chinese
>> Post: send python-chinese在lists.python.cn
>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>     
>
> = = = = = = = = = = = = = = = = = = = =
> 			
>
>         致
> 礼!
>  
> 				 
>         赵威
>         zhaowei在pythonid.com
>           2007-12-12
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月12日 星期三 11:11

yuan xuan xuanyuan14.leo在gmail.com
星期三 十二月 12 11:11:19 HKT 2007

Downloading ....limodo辛苦了。。。

2007/12/12, limodou <limodou在gmail.com>:
>
> Bug fix verion.
>
>    1. Remove profile invoke(big mistake)
>    2. Fix svn plugin checkout bug
>
> Download:
> http://ulipad.googlecode.com/files/ulipad.3.8.1.zip
> http://ulipad.googlecode.com/files/ulipad.3.8.1.exe
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20071212/7f19fbbe/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月12日 星期三 11:21

beck917 beck917在gmail.com
星期三 十二月 12 11:21:34 HKT 2007

°æ±¾¸üÐÂÕæ¿ì~Ö¾´~~

2007/12/12, yuan xuan <xuanyuan14.leo在gmail.com>:
>
> Downloading ....limodoÐÁ¿àÁË¡£¡£¡£
>
> 2007/12/12, limodou <limodou在gmail.com>:
> >
> > Bug fix verion.
> >
> >    1. Remove profile invoke(big mistake)
> >    2. Fix svn plugin checkout bug
> >
> > Download:
> > http://ulipad.googlecode.com/files/ulipad.3.8.1.zip
> > http://ulipad.googlecode.com/files/ulipad.3.8.1.exe
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071212/1ca82ae3/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月12日 星期三 11:22

大郎 iexper在gmail.com
星期三 十二月 12 11:22:16 HKT 2007

¸ÕÔçÉϸüÐÂÁËÒ»ÏÂ,
1, "°ïÖú - Ä£¿é°ïÖúÐÅÏ¢", ±»´ò¿ªÁËÁ½´Î
2, ÉϴθúlimodouÌáÁËһϹØÓÚÓþÃÁË»áCPU¸ßÕ¼(win Ô´Âë°æ), 20%ÒÔÉÏ, ²»ÖªÆäËûÅóÓÑʹÓÃʱÊÇ·ñÓÐÓöµ½Õâ¸öÎÊÌâ?

On Dec 12, 2007 11:11 AM, yuan xuan <xuanyuan14.leo在gmail.com> wrote:

> Downloading ....limodoÐÁ¿àÁË¡£¡£¡£
>
> 2007/12/12, limodou <limodou在gmail.com>:
> >
> > Bug fix verion.
> >
> >    1. Remove profile invoke(big mistake)
> >    2. Fix svn plugin checkout bug
> >
> > Download:
> > http://ulipad.googlecode.com/files/ulipad.3.8.1.zip
> > http://ulipad.googlecode.com/files/ulipad.3.8.1.exe
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
http://del.icio.us/iexper
http://twitter.com/qichangxing
http://webpy.org
Gtalk: iexper(at)gmail.com
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071212/243446eb/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月12日 星期三 11:34

Li Qingfeng liqfemail在gmail.com
星期三 十二月 12 11:34:35 HKT 2007

¸ù¾ÝÎÒµÄÀí½â£¬Ò»¸öºÃµÄGUIÉè¼Æ¹¤¾ßºÍÒ»¸öÁ¼ºÃIDEµÄ¼¯³É¶ÔÒ»ÖÖÓïÑÔµÄÍƹã¾ßÓкܴóµÄ×÷Óã¨ÓÈÆäÊÇ×ÀÃæÈí¼þ¿ª·¢·½Ã棩¡£ÓÃUlipad±àд´úÂëÒѾ­ºÜÓÅÐãÁË£¬Èç¹ûUlipadÄܹ»½øÒ»²½¼¯³ÉÓÅÐãµÄGUIÉè¼ÆµÄ¹¦ÄÜ£¬ÄÇô¶ÔÓÚpythonµÄÆÕ¼°ÕæµÄÊǹ¦µÂÎÞÁ¿ÁË¡£

ÔÚ07-12-12£¬beck917 <beck917在gmail.com> дµÀ£º
>
> °æ±¾¸üÐÂÕæ¿ì~Ö¾´~~
>
> 2007/12/12, yuan xuan <xuanyuan14.leo在gmail.com>:
> >
> > Downloading ....limodoÐÁ¿àÁË¡£¡£¡£
> >
> > 2007/12/12, limodou <limodou在gmail.com>:
> > >
> > > Bug fix verion.
> > >
> > >    1. Remove profile invoke(big mistake)
> > >    2. Fix svn plugin checkout bug
> > >
> > > Download:
> > > http://ulipad.googlecode.com/files/ulipad.3.8.1.zip
> > > http://ulipad.googlecode.com/files/ulipad.3.8.1.exe
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071212/6bac93a1/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月12日 星期三 11:41

Fenix fenixkis在tom.com
星期三 十二月 12 11:41:23 HKT 2007

一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20071212/1f1f8375/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月12日 星期三 13:01

limodou limodou在gmail.com
星期三 十二月 12 13:01:16 HKT 2007

2007/12/12 Fenix <fenixkis在tom.com>:
>
>  跟svn咋结合的?哪位高人指点一下呗
>
>  pysvn我也装了
>
安装了pysvn之后,它是在目录浏览窗口中进行工作的。如按F2可以打开目录浏览窗口。此时在右键菜单中,可以看到有svn
checkout和svn commands。如果你已经添加有目录,而且这个目录还是一个svn目录,那么它还会有更关的svn的菜单可以使用。

-- 
I like python!
UliPad <>: http://code.google.com/p/ulipad/
meide <>: http://code.google.com/p/meide/
My Blog: http://www.donews.net/limodou

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月12日 星期三 21:16

shhgs shhgs.efhilt在gmail.com
星期三 十二月 12 21:16:58 HKT 2007

是服务器端的问题还是你程序的问题?很可能人家把你这个IP加进黑名单了,程序怎么改都不行了。

你可以考虑自己建一个邮件服务器,邮件全部发给这个邮件服务器,让它帮着转发。

On Dec 11, 2007 8:52 PM, Romit <m_list在126.com> wrote:
> 确实是反垃圾邮件的问题,该企业会在月末向员工发送业绩、工资等信息,所以发
> 送邮件量会比较大,我想在邮件服务器禁止发送后,程序自动等待10分钟后重试,
> 但是每次SMTP服务器拒绝以后,随后会自动断开连接,你帮忙看一下程序存在什么
> 问题。
> for a in mbl:
>
> subject=self.mngCltXML.get_widget('entry8').get_text().encode('gb2312')
>
> text=self.mngCltXML.get_widget('textview1').get_buffer().get_text(self.mngCltXML.get_widget('textview1').get_buffer().get_start_iter(),self.mngCltXML.get_widget('textview1').get_buffer().get_end_iter()).encode('gb2312')
>             msg=MIMEText(text,_subtype='plain',_charset='GB2312')
>
>             msg['Subject']=subject
>             msg['From']=conf['user']
>             msg['To']=str(a)+'@sx.133165.com'
>
>             try:
>                 server=smtplib.SMTP(conf['host'],conf['port'])
>                 server.set_debuglevel(0)
>             except smtplib.SMTPException:
>
> cid_except=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
> exception class for all exceptions raised by this module.')
>
> self.mngCltXML.get_widget('statusbar1').push(cid_except,u'请更换信箱,服
> 务器拒绝')
>                 time.sleep(50)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_except)
>             except smtplib.SMTPServerDisconnected:
>
> cid_sdiscn=self.mngCltXML.get_widget('statusbar1').get_context_id('Server
> disconnectiod')
>
> self.mngCltXML.get_widget('statusbar1').pusb(cid_sdiscn,u'服务器连接中断')
>                 time.sleep(5)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_sdiscn)
>             except smtplib.SMTPResponseException:
>
> cid_rsp=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
> class for all exceptions that include an SMTP error code. These
> exceptions are generated in some instances when the SMTP server returns
> an error code. The error code is stored in the smtp_code attribute of
> the error, and the smtp_error attribute is set to the error message.')
>                 self.mngCltXML.get_widget('statusbar1').push(cid_rsp,u'
> 服务器响应错误')
>                 time.sleep(5)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_rsp)
>             except smtplib.SMTPSenderRefused:
>
> cid_srfus=self.mngCltXML.get_widget('statusbar1').get_context_id('Sender
> address refused. In addition to the attributes set by on all
> SMTPResponseException exceptions, this sets `sender\' to the string that
> the SMTP server refused.')
>
> self.mngCltXML.get_widget('statusbar1').push(cid_srfus,u'发件地址被拒绝')
>                 time.sleep(600)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_srfus)
>             except smtplib.SMTPRecipientsRefused:
>                 #如果收件人不存在,直接跳过
>                 continue
>             except smtplib.SMTPDataError:
>
> cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server replied with an unexpected error code (other than a refusal of a
> recipient).')
>                 self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
> 服务器返回错误')
>                 time.sleep(5)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>             except smtplib.SMTPConnectError:
>
> cid_conn=self.mngCltXML.get_widget('statusbar1').get_context_id('Error
> occurred during establishment of a connection with the server.')
>                 self.mngCltXML.get_widget('statusbar1').push(cid_conn,u'
> 与服务器连接错误,请更换信箱')
>                 time.sleep(50)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_conn)
>             except smtplib.SMTPHeloError:
>
> cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server didn\'t reply properly to the "HELO" greeting.')
>                 self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
> 服务器未正确相应')
>                 time.sleep(5)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>
>
>             try:
>                 server.login(conf['user'],conf['passwd'])
>             except smtplib.SMTPAuthenticationError:
>
> cid_auth=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server didn\'t accept the username/password combination.')
>                 self.mngCltXML.get_widget('statusbar1').push(cid_auth,u'
> 用户名或者密码错误,请在SMTP 设置输入正确的用户和密码')
>                 time.sleep(5)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_auth)
>             except smtplib.SMTPHeloError:
>
> cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server didn\'t reply properly to the "HELO" greeting.')
>                 self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
> 服务器未正确相应')
>                 time.sleep(5)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>             except smtplib.SMTPError:
>
> cid_err=self.mngCltXML.get_widget('statusbar1').get_context_id('No
> suitable authentication method was found')
>                 mngCltXML.get_widget('statusbar1').push(cid_err,u'验证方
> 法不匹配')
>                 break
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_err)
>
>
>             try:
>                 server.sendmail(conf['user'],
> str(a[0])+'@sx.133165.com',msg.as_string())
>             except smtplib.SMTPRecipientsRefused:
>                 #如果收件人不存在,直接跳过
>                 continue
>             except smtplib.SMTPHeloError:
>
> cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server didn\'t reply properly to the "HELO" greeting.')
>                 self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
> 服务器未正确相应')
>                 time.sleep(5)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>             except smtplib.SMTPSenderRefused:
>                 # 发件地址被拒绝通常是由于发送大量电子邮件爱你导致,所以
> 休眠一段时间后重复发送
>                 server.close()
>                 time.sleep(600)
>                 server=smtplib.SMTP(conf['host'],conf['port'])
>                 server.server.login(conf['user'],conf['passwd'])
>
>             except smtplib.SMTPDataError:
>
> cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server replied with an unexpected error code (other than a refusal of a
> recipient).')
>                 self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
> 服务器返回错误')
>                 time.sleep(5)
>                 self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>
>             server.quit()
>
>
> 赵威 写道:
>
> > Romit,您好!
> >
> >       又是遇到反垃圾邮件了...
> > 异常可以捕获到的,应该是你捕获的地方不对
> >
> > ======= 2007-12-09 12:28:52 您在来信中写道:=======
> >
> >
> >> 我为某企业写了一个向该企业员工群发电子邮件的程序,使用的是smtplib。在通
> >> 过smtp协议迭代群发邮件的时候,特别是连续发送超过32份的时候,smtp服务器拒
> >> 绝我发送请求的时候,smtplib通常会抛出一个异常:
> >> smtplib.SMTPException
> >> 紧跟着是另外一个异常:
> >> smtplib.SMTPServerDisconnected
> >> 这个异常没办法捕获到,虽然我的程序里有这个异常处理子句。
> >> 我该怎么处理这个异常?
> >>
> >> _______________________________________________
> >> python-chinese
> >> Post: send python-chinese在lists.python.cn
> >> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> >> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> >> Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >>
> >
> > = = = = = = = = = = = = = = = = = = = =
> >
> >
> > 致
> > 礼!
> >
> >
> > 赵威
> > zhaowei在pythonid.com
> > 2007-12-12
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月13日 星期四 10:30

yuan xuan xuanyuan14.leo在gmail.com
星期四 十二月 13 10:30:24 HKT 2007

昨天更新后,原来能运行得程序报错了,运行只有print语句的程序都报错,卸载重装,也不行。
报错内容:Excution of command '""C:\Python24\python.exe"" -u
"D:\python\traning\test\param.py"' failed(error 2:系统找不到指定的文件)

我现在的环境是:
win xp sp2
Python 2.4.4 Stackless 3.1b3 060516 (#71, Jan 27 2007, 21:48:58) [MSC v.131032
bit (Intel)] on win32
在Ulipad 3.7下能正常运行。

迫不得已,回退到Ulipad 3.7下了,程序运行都正常了。
-------------- 下一部分 --------------
一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20071213/daa35103/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月13日 星期四 10:40

limodou limodou在gmail.com
星期四 十二月 13 10:40:18 HKT 2007

On Dec 13, 2007 10:30 AM, yuan xuan <xuanyuan14.leo在gmail.com> wrote:
> 昨天更新后,原来能运行得程序报错了,运行只有print语句的程序都报错,卸载重装,也不行。
> 报错内容:Excution of command '""C:\Python24\python.exe"" -u
> "D:\python\traning\test\param.py"' failed(error 2:系统找不到指定的文件)
>
> 我现在的环境是:
>  win xp sp2
> Python 2.4.4 Stackless 3.1b3 060516 (#71, Jan 27 2007, 21:48:58) [MSC v.1310
> 32
> bit (Intel)] on win32
> 在Ulipad 3.7下能正常运行。
>
> 迫不得已,回退到Ulipad 3.7下了,程序运行都正常了。
>
我这里没有这个问题。请检查你的python解释器是不是在匹配上加了双引号,如果是,去掉就可以了。UliPad在执行时会自动在相应的文件名前后加双引号,这是为了避免在windows下,目录可能有空格的情况。

-- 
I like python!
UliPad <>: http://code.google.com/p/ulipad/
meide <>: http://code.google.com/p/meide/
My Blog: http://www.donews.net/limodou

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月13日 星期四 11:29

yuan xuan xuanyuan14.leo在gmail.com
星期四 十二月 13 11:29:52 HKT 2007

不好意思,请问如何检查:python解释器是不是在匹配上加了双引号?
为什么ulipad 3.7下运行正常呢?

在07-12-13,limodou <limodou在gmail.com> 写道:
>
> On Dec 13, 2007 10:30 AM, yuan xuan <xuanyuan14.leo在gmail.com> wrote:
> > 昨天更新后,原来能运行得程序报错了,运行只有print语句的程序都报错,卸载重装,也不行。
> > 报错内容:Excution of command '""C:\Python24\python.exe"" -u
> > "D:\python\traning\test\param.py"' failed(error 2:系统找不到指定的文件)
> >
> > 我现在的环境是:
> >  win xp sp2
> > Python 2.4.4 Stackless 3.1b3 060516 (#71, Jan 27 2007, 21:48:58) [MSC
> v.1310
> > 32
> > bit (Intel)] on win32
> > 在Ulipad 3.7下能正常运行。
> >
> > 迫不得已,回退到Ulipad 3.7下了,程序运行都正常了。
> >
>
> 我这里没有这个问题。请检查你的python解释器是不是在匹配上加了双引号,如果是,去掉就可以了。UliPad在执行时会自动在相应的文件名前后加双引号,这是为了避免在windows下,目录可能有空格的情况。
>
> --
> I like python!
> UliPad <>: http://code.google.com/p/ulipad/
> meide <>: http://code.google.com/p/meide/
> My Blog: http://www.donews.net/limodou
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20071213/0c9a7792/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月14日 星期五 09:33

@@ askfor在gmail.com
星期五 十二月 14 09:33:04 HKT 2007

Èç¹ûÄãÈ·ÈÏ·¢32¾Í»á´¥·¢·´À¬»øÓʼþ¡£
ÄǾÍÿ10·ÖÖÓ·¢31·âºÃÁË¡£¡£¡£


On 12/12/07, Romit <m_list在126.com> wrote:
>
> ȷʵÊÇ·´À¬»øÓʼþµÄÎÊÌ⣬¸ÃÆóÒµ»áÔÚÔÂÄ©ÏòÔ±¹¤·¢ËÍÒµ¼¨¡¢¹¤×ʵÈÐÅÏ¢£¬ËùÒÔ·¢
> ËÍÓʼþÁ¿»á±È½Ï´ó£¬ÎÒÏëÔÚÓʼþ·þÎñÆ÷½ûÖ¹·¢Ëͺ󣬳ÌÐò×Ô¶¯µÈ´ý10·ÖÖÓºóÖØÊÔ£¬
> µ«ÊÇÿ´ÎSMTP·þÎñÆ÷¾Ü¾øÒÔºó£¬Ëæºó»á×Ô¶¯¶Ï¿ªÁ¬½Ó£¬Äã°ï濴һϳÌÐò´æÔÚʲô
> ÎÊÌâ¡£
> for a in mbl:
>
> subject=self.mngCltXML.get_widget('entry8').get_text().encode('gb2312')
>
> text=self.mngCltXML.get_widget('textview1').get_buffer().get_text(
> self.mngCltXML.get_widget('textview1').get_buffer().get_start_iter(),
> self.mngCltXML.get_widget
> ('textview1').get_buffer().get_end_iter()).encode('gb2312')
>            msg=MIMEText(text,_subtype='plain',_charset='GB2312')
>
>            msg['Subject']=subject
>            msg['From']=conf['user']
>            msg['To']=str(a)+'@sx.133165.com'
>
>            try:
>                server=smtplib.SMTP(conf['host'],conf['port'])
>                server.set_debuglevel(0)
>            except smtplib.SMTPException:
>
> cid_except=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
> exception class for all exceptions raised by this module.')
>
> self.mngCltXML.get_widget('statusbar1').push(cid_except,u'Çë¸ü»»ÐÅÏ䣬·þ
> ÎñÆ÷¾Ü¾ø')
>                time.sleep(50)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_except)
>            except smtplib.SMTPServerDisconnected:
>
> cid_sdiscn=self.mngCltXML.get_widget('statusbar1').get_context_id('Server
> disconnectiod')
>
> self.mngCltXML.get_widget('statusbar1').pusb(cid_sdiscn,u'·þÎñÆ÷Á¬½ÓÖжÏ')
>                time.sleep(5)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_sdiscn)
>            except smtplib.SMTPResponseException:
>
> cid_rsp=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
> class for all exceptions that include an SMTP error code. These
> exceptions are generated in some instances when the SMTP server returns
> an error code. The error code is stored in the smtp_code attribute of
> the error, and the smtp_error attribute is set to the error message.')
>                self.mngCltXML.get_widget('statusbar1').push(cid_rsp,u'
> ·þÎñÆ÷ÏìÓ¦´íÎó')
>                time.sleep(5)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_rsp)
>            except smtplib.SMTPSenderRefused:
>
> cid_srfus=self.mngCltXML.get_widget('statusbar1').get_context_id('Sender
> address refused. In addition to the attributes set by on all
> SMTPResponseException exceptions, this sets `sender\' to the string that
> the SMTP server refused.')
>
> self.mngCltXML.get_widget('statusbar1').push(cid_srfus,u'·¢¼þµØÖ·±»¾Ü¾ø')
>                time.sleep(600)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_srfus)
>            except smtplib.SMTPRecipientsRefused:
>                #Èç¹ûÊÕ¼þÈ˲»´æÔÚ£¬Ö±½ÓÌø¹ý
>                continue
>            except smtplib.SMTPDataError:
>
> cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server replied with an unexpected error code (other than a refusal of a
> recipient).')
>                self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
> ·þÎñÆ÷·µ»Ø´íÎó')
>                time.sleep(5)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>            except smtplib.SMTPConnectError:
>
> cid_conn=self.mngCltXML.get_widget('statusbar1').get_context_id('Error
> occurred during establishment of a connection with the server.')
>                self.mngCltXML.get_widget('statusbar1').push(cid_conn,u'
> Óë·þÎñÆ÷Á¬½Ó´íÎó£¬Çë¸ü»»ÐÅÏä')
>                time.sleep(50)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_conn)
>            except smtplib.SMTPHeloError:
>
> cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server didn\'t reply properly to the "HELO" greeting.')
>                self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
> ·þÎñÆ÷δÕýÈ·ÏàÓ¦')
>                time.sleep(5)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>
>
>            try:
>                server.login(conf['user'],conf['passwd'])
>            except smtplib.SMTPAuthenticationError:
>
> cid_auth=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server didn\'t accept the username/password combination.')
>                self.mngCltXML.get_widget('statusbar1').push(cid_auth,u'
> Óû§Ãû»òÕßÃÜÂë´íÎó£¬ÇëÔÚSMTP ÉèÖÃÊäÈëÕýÈ·µÄÓû§ºÍÃÜÂë')
>                time.sleep(5)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_auth)
>            except smtplib.SMTPHeloError:
>
> cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server didn\'t reply properly to the "HELO" greeting.')
>                self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
> ·þÎñÆ÷δÕýÈ·ÏàÓ¦')
>                time.sleep(5)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>            except smtplib.SMTPError:
>
> cid_err=self.mngCltXML.get_widget('statusbar1').get_context_id('No
> suitable authentication method was found')
>                mngCltXML.get_widget('statusbar1').push(cid_err,u'ÑéÖ¤·½
> ·¨²»Æ¥Åä')
>                break
>                self.mngCltXML.get_widget('statusbar1').pop(cid_err)
>
>
>            try:
>                server.sendmail(conf['user'],
> str(a[0])+'@sx.133165.com',msg.as_string())
>            except smtplib.SMTPRecipientsRefused:
>                #Èç¹ûÊÕ¼þÈ˲»´æÔÚ£¬Ö±½ÓÌø¹ý
>                continue
>            except smtplib.SMTPHeloError:
>
> cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server didn\'t reply properly to the "HELO" greeting.')
>                self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
> ·þÎñÆ÷δÕýÈ·ÏàÓ¦')
>                time.sleep(5)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>            except smtplib.SMTPSenderRefused:
>                # ·¢¼þµØÖ·±»¾Ü¾øͨ³£ÊÇÓÉÓÚ·¢ËÍ´óÁ¿µç×ÓÓʼþ°®Äãµ¼Ö£¬ËùÒÔ
> ÐÝÃßÒ»¶Îʱ¼äºóÖظ´·¢ËÍ
>                server.close()
>                time.sleep(600)
>                server=smtplib.SMTP(conf['host'],conf['port'])
>                server.server.login(conf['user'],conf['passwd'])
>
>            except smtplib.SMTPDataError:
>
> cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
> server replied with an unexpected error code (other than a refusal of a
> recipient).')
>                self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
> ·þÎñÆ÷·µ»Ø´íÎó')
>                time.sleep(5)
>                self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>
>            server.quit()
>
>
> ÕÔÍþ дµÀ:
> > Romit,ÄúºÃ£¡
> >
> >       ÓÖÊÇÓöµ½·´À¬»øÓʼþÁË...
> > Òì³£¿ÉÒÔ²¶»ñµ½µÄ,Ó¦¸ÃÊÇÄ㲶»ñµÄµØ·½²»¶Ô
> >
> > ======= 2007-12-09 12:28:52 ÄúÔÚÀ´ÐÅÖÐдµÀ£º=======
> >
> >
> >> ÎÒΪijÆóҵдÁËÒ»¸öÏò¸ÃÆóÒµÔ±¹¤Èº·¢µç×ÓÓʼþµÄ³ÌÐò£¬Ê¹ÓõÄÊÇsmtplib¡£ÔÚͨ
> >> ¹ýsmtpЭÒéµü´úȺ·¢ÓʼþµÄʱºò£¬ÌرðÊÇÁ¬Ðø·¢Ëͳ¬¹ý32·ÝµÄʱºò£¬smtp·þÎñÆ÷¾Ü
> >> ¾øÎÒ·¢ËÍÇëÇóµÄʱºò£¬smtplibͨ³£»áÅ׳öÒ»¸öÒì³££º
> >> smtplib.SMTPException
> >> ½ô¸ú×ÅÊÇÁíÍâÒ»¸öÒì³££º
> >> smtplib.SMTPServerDisconnected
> >> Õâ¸öÒ쳣û°ì·¨²¶»ñµ½£¬ËäÈ»ÎҵijÌÐòÀïÓÐÕâ¸öÒì³£´¦Àí×Ӿ䡣
> >> ÎÒ¸ÃÔõô´¦ÀíÕâ¸öÒì³££¿
> >>
> >> _______________________________________________
> >> python-chinese
> >> Post: send python-chinese在lists.python.cn
> >> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> >> Unsubscribe: send unsubscribe to
> python-chinese-request在lists.python.cn
> >> Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >>
> >
> > = = = = = = = = = = = = = = = = = = = =
> >
> >
> > ÖÂ
> > Àñ£¡
> >
> >
> > ÕÔÍþ
> > zhaowei在pythonid.com
> > 2007-12-12
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071214/bd00151a/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月14日 星期五 09:41

Romit m_list在126.com
星期五 十二月 14 09:41:38 HKT 2007

126是32份,如意信箱又是一个标准,每家的标准都不一样的。所以我的想法是检
测到smtpserverdisconnected后休眠10分钟后,再发送,这样程序的适应性会比较强。

@@ 写道:
> 如果你确认发32就会触发反垃圾邮件。
> 那就每10分钟发31封好了。。。
>
> On 12/12/07, *Romit* <m_list在126.com m_list在126.com>> wrote:
>
>     确实是反垃圾邮件的问题,该企业会在月末向员工发送业绩、工资等信息,
>     所以发
>     送邮件量会比较大,我想在邮件服务器禁止发送后,程序自动等待10分钟后
>     重试,
>     但是每次SMTP服务器拒绝以后,随后会自动断开连接,你帮忙看一下程序存
>     在什么
>     问题。
>     for a in mbl:
>
>     subject=self.mngCltXML.get_widget('entry8').get_text().encode('gb2312')
>
>     text=self.mngCltXML.get_widget('textview1').get_buffer().get_text(self.mngCltXML.get_widget
>     ('textview1').get_buffer().get_start_iter(),self.mngCltXML.get_widget('textview1').get_buffer().get_end_iter()).encode('gb2312')
>     msg=MIMEText(text,_subtype='plain',_charset='GB2312')
>
>     msg['Subject']=subject
>     msg['From']=conf['user']
>     msg['To']=str(a)+'@sx.133165.com <http://sx.133165.com>'
>
>     try:
>     server=smtplib.SMTP(conf['host'],conf['port'])
>     server.set_debuglevel(0)
>     except smtplib.SMTPException:
>
>     cid_except=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
>
>     exception class for all exceptions raised by this module.')
>
>     self.mngCltXML.get_widget('statusbar1').push(cid_except,u'请更换信
>     箱,服
>     务器拒绝')
>     time.sleep(50)
>     self.mngCltXML.get_widget ('statusbar1').pop(cid_except)
>     except smtplib.SMTPServerDisconnected:
>
>     cid_sdiscn=self.mngCltXML.get_widget('statusbar1').get_context_id('Server
>     disconnectiod')
>
>     self.mngCltXML.get_widget ('statusbar1').pusb(cid_sdiscn,u'服务器
>     连接中断')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_sdiscn)
>     except smtplib.SMTPResponseException :
>
>     cid_rsp=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
>     class for all exceptions that include an SMTP error code. These
>     exceptions are generated in some instances when the SMTP server
>     returns
>     an error code. The error code is stored in the smtp_code attribute of
>     the error, and the smtp_error attribute is set to the error message.')
>     self.mngCltXML.get_widget('statusbar1').push(cid_rsp,u'
>     服务器响应错误')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_rsp)
>     except smtplib.SMTPSenderRefused:
>
>     cid_srfus=self.mngCltXML.get_widget('statusbar1').get_context_id('Sender
>
>     address refused. In addition to the attributes set by on all
>     SMTPResponseException exceptions, this sets `sender\' to the
>     string that
>     the SMTP server refused.')
>
>     self.mngCltXML.get_widget('statusbar1').push(cid_srfus,u'发件地址
>     被拒绝')
>     time.sleep(600)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_srfus)
>     except smtplib.SMTPRecipientsRefused:
>     #如果收件人不存在,直接跳过
>     continue
>     except smtplib.SMTPDataError:
>
>     cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>     server replied with an unexpected error code (other than a refusal
>     of a
>     recipient).')
>     self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
>     服务器返回错误')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>     except smtplib.SMTPConnectError:
>
>     cid_conn=self.mngCltXML.get_widget('statusbar1').get_context_id('Error
>     occurred during establishment of a connection with the server.')
>     self.mngCltXML.get_widget ('statusbar1').push(cid_conn,u'
>     与服务器连接错误,请更换信箱')
>     time.sleep(50)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_conn)
>     except smtplib.SMTPHeloError :
>
>     cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>     server didn\'t reply properly to the "HELO" greeting.')
>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>     服务器未正确相应')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>
>
>     try:
>     server.login(conf['user'],conf['passwd'])
>     except smtplib.SMTPAuthenticationError:
>
>     cid_auth=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>     server didn\'t accept the username/password combination.')
>     self.mngCltXML.get_widget('statusbar1').push(cid_auth,u'
>     用户名或者密码错误,请在SMTP 设置输入正确的用户和密码')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_auth)
>     except smtplib.SMTPHeloError:
>
>     cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>     server didn\'t reply properly to the "HELO" greeting.')
>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>     服务器未正确相应')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>     except smtplib.SMTPError :
>
>     cid_err=self.mngCltXML.get_widget('statusbar1').get_context_id('No
>     suitable authentication method was found')
>     mngCltXML.get_widget('statusbar1').push(cid_err,u'验证方
>     法不匹配')
>     break
>     self.mngCltXML.get_widget('statusbar1').pop(cid_err)
>
>
>     try:
>     server.sendmail(conf['user'],
>     str(a[0])+'@ sx.133165.com <http://sx.133165.com>',msg.as_string())
>     except smtplib.SMTPRecipientsRefused:
>     #如果收件人不存在,直接跳过
>     continue
>     except smtplib.SMTPHeloError:
>
>     cid_helo=self.mngCltXML.get_widget ('statusbar1').get_context_id('The
>     server didn\'t reply properly to the "HELO" greeting.')
>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>     服务器未正确相应')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>     except smtplib.SMTPSenderRefused:
>     # 发件地址被拒绝通常是由于发送大量电子邮件爱你导致,所以
>     休眠一段时间后重复发送
>     server.close()
>     time.sleep(600)
>     server=smtplib.SMTP(conf['host'],conf['port'])
>     server.server.login(conf['user'],conf['passwd'])
>
>     except smtplib.SMTPDataError:
>
>     cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>     server replied with an unexpected error code (other than a refusal
>     of a
>     recipient).')
>     self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
>     服务器返回错误')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>
>     server.quit()
>
>
>     赵威 写道:
>     > Romit,您好!
>     >
>     > 又是遇到反垃圾邮件了...
>     > 异常可以捕获到的,应该是你捕获的地方不对
>     >
>     > ======= 2007-12-09 12:28:52 您在来信中写道:=======
>     >
>     >
>     >> 我为某企业写了一个向该企业员工群发电子邮件的程序,使用的是
>     smtplib。在通
>     >> 过smtp协议迭代群发邮件的时候,特别是连续发送超过32份的时候,
>     smtp服务器拒
>     >> 绝我发送请求的时候,smtplib通常会抛出一个异常:
>     >> smtplib.SMTPException
>     >> 紧跟着是另外一个异常:
>     >> smtplib.SMTPServerDisconnected
>     >> 这个异常没办法捕获到,虽然我的程序里有这个异常处理子句。
>     >> 我该怎么处理这个异常?
>     >>
>     >> _______________________________________________
>     >> python-chinese
>     >> Post: send python-chinese在lists.python.cn
>     python-chinese在lists.python.cn>
>     >> Subscribe: send subscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     >> Unsubscribe: send unsubscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     >> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>     >>
>     >
>     > = = = = = = = = = = = = = = = = = = = =
>     >
>     >
>     > 致
>     > 礼!
>     >
>     >
>     > 赵威
>     > zhaowei在pythonid.com zhaowei在pythonid.com>
>     > 2007-12-12
>     >
>     > _______________________________________________
>     > python-chinese
>     > Post: send python-chinese在lists.python.cn
>     python-chinese在lists.python.cn>
>     > Subscribe: send subscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     > Unsubscribe: send unsubscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>     _______________________________________________
>     python-chinese
>     Post: send python-chinese在lists.python.cn
>     python-chinese在lists.python.cn>
>     Subscribe: send subscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     Unsubscribe: send unsubscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月14日 星期五 10:03

GuoYao guoyao在gmail.com
星期五 十二月 14 10:03:19 HKT 2007

他的意思好像就是无法捕获服务器主动断开连接 这个异常。

-----Original Message-----
From: python-chinese-bounces在lists.python.cn
[mailto:python-chinese-bounces在lists.python.cn] On Behalf Of Romit
Sent: 2007年12月14日 9:42
To: python-chinese在lists.python.cn
Subject: Re: [python-chinese] smtplib级联异常

126是32份,如意信箱又是一个标准,每家的标准都不一样的。所以我的想法是检
测到smtpserverdisconnected后休眠10分钟后,再发送,这样程序的适应性会比较强。

@@ 写道:
> 如果你确认发32就会触发反垃圾邮件。
> 那就每10分钟发31封好了。。。
>
> On 12/12/07, *Romit* <m_list在126.com m_list在126.com>> wrote:
>
>     确实是反垃圾邮件的问题,该企业会在月末向员工发送业绩、工资等信息,
>     所以发
>     送邮件量会比较大,我想在邮件服务器禁止发送后,程序自动等待10分钟后
>     重试,
>     但是每次SMTP服务器拒绝以后,随后会自动断开连接,你帮忙看一下程序存
>     在什么
>     问题。
>     for a in mbl:
>
>     
> subject=self.mngCltXML.get_widget('entry8').get_text().encode('gb2312'
> )
>
>
text=self.mngCltXML.get_widget('textview1').get_buffer().get_text(self.mngCl
tXML.get_widget
>
('textview1').get_buffer().get_start_iter(),self.mngCltXML.get_widget('textv
iew1').get_buffer().get_end_iter()).encode('gb2312')
>     msg=MIMEText(text,_subtype='plain',_charset='GB2312')
>
>     msg['Subject']=subject
>     msg['From']=conf['user']
>     msg['To']=str(a)+'@sx.133165.com <http://sx.133165.com>'
>
>     try:
>     server=smtplib.SMTP(conf['host'],conf['port'])
>     server.set_debuglevel(0)
>     except smtplib.SMTPException:
>
>     
> cid_except=self.mngCltXML.get_widget('statusbar1').get_context_id('Bas
> e
>
>     exception class for all exceptions raised by this module.')
>
>     self.mngCltXML.get_widget('statusbar1').push(cid_except,u'请更换信
>     箱,服
>     务器拒绝')
>     time.sleep(50)
>     self.mngCltXML.get_widget ('statusbar1').pop(cid_except)
>     except smtplib.SMTPServerDisconnected:
>
>
cid_sdiscn=self.mngCltXML.get_widget('statusbar1').get_context_id('Server
>     disconnectiod')
>
>     self.mngCltXML.get_widget ('statusbar1').pusb(cid_sdiscn,u'服务器
>     连接中断')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_sdiscn)
>     except smtplib.SMTPResponseException :
>
>     cid_rsp=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
>     class for all exceptions that include an SMTP error code. These
>     exceptions are generated in some instances when the SMTP server
>     returns
>     an error code. The error code is stored in the smtp_code attribute of
>     the error, and the smtp_error attribute is set to the error message.')
>     self.mngCltXML.get_widget('statusbar1').push(cid_rsp,u'
>     服务器响应错误')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_rsp)
>     except smtplib.SMTPSenderRefused:
>
>     
> cid_srfus=self.mngCltXML.get_widget('statusbar1').get_context_id('Send
> er
>
>     address refused. In addition to the attributes set by on all
>     SMTPResponseException exceptions, this sets `sender\' to the
>     string that
>     the SMTP server refused.')
>
>     self.mngCltXML.get_widget('statusbar1').push(cid_srfus,u'发件地址
>     被拒绝')
>     time.sleep(600)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_srfus)
>     except smtplib.SMTPRecipientsRefused:
>     #如果收件人不存在,直接跳过
>     continue
>     except smtplib.SMTPDataError:
>
>     cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>     server replied with an unexpected error code (other than a refusal
>     of a
>     recipient).')
>     self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
>     服务器返回错误')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>     except smtplib.SMTPConnectError:
>
>     cid_conn=self.mngCltXML.get_widget('statusbar1').get_context_id('Error
>     occurred during establishment of a connection with the server.')
>     self.mngCltXML.get_widget ('statusbar1').push(cid_conn,u'
>     与服务器连接错误,请更换信箱')
>     time.sleep(50)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_conn)
>     except smtplib.SMTPHeloError :
>
>     cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>     server didn\'t reply properly to the "HELO" greeting.')
>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>     服务器未正确相应')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>
>
>     try:
>     server.login(conf['user'],conf['passwd'])
>     except smtplib.SMTPAuthenticationError:
>
>     cid_auth=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>     server didn\'t accept the username/password combination.')
>     self.mngCltXML.get_widget('statusbar1').push(cid_auth,u'
>     用户名或者密码错误,请在SMTP 设置输入正确的用户和密码')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_auth)
>     except smtplib.SMTPHeloError:
>
>     cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>     server didn\'t reply properly to the "HELO" greeting.')
>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>     服务器未正确相应')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>     except smtplib.SMTPError :
>
>     cid_err=self.mngCltXML.get_widget('statusbar1').get_context_id('No
>     suitable authentication method was found')
>     mngCltXML.get_widget('statusbar1').push(cid_err,u'验证方
>     法不匹配')
>     break
>     self.mngCltXML.get_widget('statusbar1').pop(cid_err)
>
>
>     try:
>     server.sendmail(conf['user'],
>     str(a[0])+'@ sx.133165.com <http://sx.133165.com>',msg.as_string())
>     except smtplib.SMTPRecipientsRefused:
>     #如果收件人不存在,直接跳过
>     continue
>     except smtplib.SMTPHeloError:
>
>     cid_helo=self.mngCltXML.get_widget ('statusbar1').get_context_id('The
>     server didn\'t reply properly to the "HELO" greeting.')
>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>     服务器未正确相应')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>     except smtplib.SMTPSenderRefused:
>     # 发件地址被拒绝通常是由于发送大量电子邮件爱你导致,所以
>     休眠一段时间后重复发送
>     server.close()
>     time.sleep(600)
>     server=smtplib.SMTP(conf['host'],conf['port'])
>     server.server.login(conf['user'],conf['passwd'])
>
>     except smtplib.SMTPDataError:
>
>     cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>     server replied with an unexpected error code (other than a refusal
>     of a
>     recipient).')
>     self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
>     服务器返回错误')
>     time.sleep(5)
>     self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>
>     server.quit()
>
>
>     赵威 写道:
>     > Romit,您好!
>     >
>     > 又是遇到反垃圾邮件了...
>     > 异常可以捕获到的,应该是你捕获的地方不对
>     >
>     > ======= 2007-12-09 12:28:52 您在来信中写道:=======
>     >
>     >
>     >> 我为某企业写了一个向该企业员工群发电子邮件的程序,使用的是
>     smtplib。在通
>     >> 过smtp协议迭代群发邮件的时候,特别是连续发送超过32份的时候,
>     smtp服务器拒
>     >> 绝我发送请求的时候,smtplib通常会抛出一个异常:
>     >> smtplib.SMTPException
>     >> 紧跟着是另外一个异常:
>     >> smtplib.SMTPServerDisconnected
>     >> 这个异常没办法捕获到,虽然我的程序里有这个异常处理子句。
>     >> 我该怎么处理这个异常?
>     >>
>     >> _______________________________________________
>     >> python-chinese
>     >> Post: send python-chinese在lists.python.cn
>     python-chinese在lists.python.cn>
>     >> Subscribe: send subscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     >> Unsubscribe: send unsubscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     >> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>     >>
>     >
>     > = = = = = = = = = = = = = = = = = = = =
>     >
>     >
>     > 致
>     > 礼!
>     >
>     >
>     > 赵威
>     > zhaowei在pythonid.com zhaowei在pythonid.com>
>     > 2007-12-12
>     >
>     > _______________________________________________
>     > python-chinese
>     > Post: send python-chinese在lists.python.cn
>     python-chinese在lists.python.cn>
>     > Subscribe: send subscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     > Unsubscribe: send unsubscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>     _______________________________________________
>     python-chinese
>     Post: send python-chinese在lists.python.cn
>     python-chinese在lists.python.cn>
>     Subscribe: send subscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     Unsubscribe: send unsubscribe to
>     python-chinese-request在lists.python.cn
>     python-chinese-request在lists.python.cn>
>     Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
> ----------------------------------------------------------------------
> --
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  
> python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese

_______________________________________________
python-chinese
Post: send python-chinese在lists.python.cn
Subscribe: send subscribe to python-chinese-request在lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月14日 星期五 10:10

Romit m_list在126.com
星期五 十二月 14 10:10:47 HKT 2007

对,就是这个意思,我想能捕获服务器主动断开连接这个异常,我的程序的灵活性
就增强了。
GuoYao 写道:
> 他的意思好像就是无法捕获服务器主动断开连接 这个异常。
>
> -----Original Message-----
> From: python-chinese-bounces在lists.python.cn
> [mailto:python-chinese-bounces在lists.python.cn] On Behalf Of Romit
> Sent: 2007年12月14日 9:42
> To: python-chinese在lists.python.cn
> Subject: Re: [python-chinese] smtplib级联异常
>
> 126是32份,如意信箱又是一个标准,每家的标准都不一样的。所以我的想法是检
> 测到smtpserverdisconnected后休眠10分钟后,再发送,这样程序的适应性会比较强。
>
> @@ 写道:
>   
>> 如果你确认发32就会触发反垃圾邮件。
>> 那就每10分钟发31封好了。。。
>>
>> On 12/12/07, *Romit* <m_list在126.com m_list在126.com>> wrote:
>>
>>     确实是反垃圾邮件的问题,该企业会在月末向员工发送业绩、工资等信息,
>>     所以发
>>     送邮件量会比较大,我想在邮件服务器禁止发送后,程序自动等待10分钟后
>>     重试,
>>     但是每次SMTP服务器拒绝以后,随后会自动断开连接,你帮忙看一下程序存
>>     在什么
>>     问题。
>>     for a in mbl:
>>
>>     
>> subject=self.mngCltXML.get_widget('entry8').get_text().encode('gb2312'
>> )
>>
>>
>>     
> text=self.mngCltXML.get_widget('textview1').get_buffer().get_text(self.mngCl
> tXML.get_widget
>   
> ('textview1').get_buffer().get_start_iter(),self.mngCltXML.get_widget('textv
> iew1').get_buffer().get_end_iter()).encode('gb2312')
>   
>>     msg=MIMEText(text,_subtype='plain',_charset='GB2312')
>>
>>     msg['Subject']=subject
>>     msg['From']=conf['user']
>>     msg['To']=str(a)+'@sx.133165.com <http://sx.133165.com>'
>>
>>     try:
>>     server=smtplib.SMTP(conf['host'],conf['port'])
>>     server.set_debuglevel(0)
>>     except smtplib.SMTPException:
>>
>>     
>> cid_except=self.mngCltXML.get_widget('statusbar1').get_context_id('Bas
>> e
>>
>>     exception class for all exceptions raised by this module.')
>>
>>     self.mngCltXML.get_widget('statusbar1').push(cid_except,u'请更换信
>>     箱,服
>>     务器拒绝')
>>     time.sleep(50)
>>     self.mngCltXML.get_widget ('statusbar1').pop(cid_except)
>>     except smtplib.SMTPServerDisconnected:
>>
>>
>>     
> cid_sdiscn=self.mngCltXML.get_widget('statusbar1').get_context_id('Server
>   
>>     disconnectiod')
>>
>>     self.mngCltXML.get_widget ('statusbar1').pusb(cid_sdiscn,u'服务器
>>     连接中断')
>>     time.sleep(5)
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_sdiscn)
>>     except smtplib.SMTPResponseException :
>>
>>     cid_rsp=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
>>     class for all exceptions that include an SMTP error code. These
>>     exceptions are generated in some instances when the SMTP server
>>     returns
>>     an error code. The error code is stored in the smtp_code attribute of
>>     the error, and the smtp_error attribute is set to the error message.')
>>     self.mngCltXML.get_widget('statusbar1').push(cid_rsp,u'
>>     服务器响应错误')
>>     time.sleep(5)
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_rsp)
>>     except smtplib.SMTPSenderRefused:
>>
>>     
>> cid_srfus=self.mngCltXML.get_widget('statusbar1').get_context_id('Send
>> er
>>
>>     address refused. In addition to the attributes set by on all
>>     SMTPResponseException exceptions, this sets `sender\' to the
>>     string that
>>     the SMTP server refused.')
>>
>>     self.mngCltXML.get_widget('statusbar1').push(cid_srfus,u'发件地址
>>     被拒绝')
>>     time.sleep(600)
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_srfus)
>>     except smtplib.SMTPRecipientsRefused:
>>     #如果收件人不存在,直接跳过
>>     continue
>>     except smtplib.SMTPDataError:
>>
>>     cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>     server replied with an unexpected error code (other than a refusal
>>     of a
>>     recipient).')
>>     self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
>>     服务器返回错误')
>>     time.sleep(5)
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>>     except smtplib.SMTPConnectError:
>>
>>     cid_conn=self.mngCltXML.get_widget('statusbar1').get_context_id('Error
>>     occurred during establishment of a connection with the server.')
>>     self.mngCltXML.get_widget ('statusbar1').push(cid_conn,u'
>>     与服务器连接错误,请更换信箱')
>>     time.sleep(50)
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_conn)
>>     except smtplib.SMTPHeloError :
>>
>>     cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>     server didn\'t reply properly to the "HELO" greeting.')
>>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>>     服务器未正确相应')
>>     time.sleep(5)
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>>
>>
>>     try:
>>     server.login(conf['user'],conf['passwd'])
>>     except smtplib.SMTPAuthenticationError:
>>
>>     cid_auth=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>     server didn\'t accept the username/password combination.')
>>     self.mngCltXML.get_widget('statusbar1').push(cid_auth,u'
>>     用户名或者密码错误,请在SMTP 设置输入正确的用户和密码')
>>     time.sleep(5)
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_auth)
>>     except smtplib.SMTPHeloError:
>>
>>     cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>     server didn\'t reply properly to the "HELO" greeting.')
>>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>>     服务器未正确相应')
>>     time.sleep(5)
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>>     except smtplib.SMTPError :
>>
>>     cid_err=self.mngCltXML.get_widget('statusbar1').get_context_id('No
>>     suitable authentication method was found')
>>     mngCltXML.get_widget('statusbar1').push(cid_err,u'验证方
>>     法不匹配')
>>     break
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_err)
>>
>>
>>     try:
>>     server.sendmail(conf['user'],
>>     str(a[0])+'@ sx.133165.com <http://sx.133165.com>',msg.as_string())
>>     except smtplib.SMTPRecipientsRefused:
>>     #如果收件人不存在,直接跳过
>>     continue
>>     except smtplib.SMTPHeloError:
>>
>>     cid_helo=self.mngCltXML.get_widget ('statusbar1').get_context_id('The
>>     server didn\'t reply properly to the "HELO" greeting.')
>>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>>     服务器未正确相应')
>>     time.sleep(5)
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>>     except smtplib.SMTPSenderRefused:
>>     # 发件地址被拒绝通常是由于发送大量电子邮件爱你导致,所以
>>     休眠一段时间后重复发送
>>     server.close()
>>     time.sleep(600)
>>     server=smtplib.SMTP(conf['host'],conf['port'])
>>     server.server.login(conf['user'],conf['passwd'])
>>
>>     except smtplib.SMTPDataError:
>>
>>     cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>     server replied with an unexpected error code (other than a refusal
>>     of a
>>     recipient).')
>>     self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
>>     服务器返回错误')
>>     time.sleep(5)
>>     self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>>
>>     server.quit()
>>
>>
>>     赵威 写道:
>>     > Romit,您好!
>>     >
>>     > 又是遇到反垃圾邮件了...
>>     > 异常可以捕获到的,应该是你捕获的地方不对
>>     >
>>     > ======= 2007-12-09 12:28:52 您在来信中写道:=======
>>     >
>>     >
>>     >> 我为某企业写了一个向该企业员工群发电子邮件的程序,使用的是
>>     smtplib。在通
>>     >> 过smtp协议迭代群发邮件的时候,特别是连续发送超过32份的时候,
>>     smtp服务器拒
>>     >> 绝我发送请求的时候,smtplib通常会抛出一个异常:
>>     >> smtplib.SMTPException
>>     >> 紧跟着是另外一个异常:
>>     >> smtplib.SMTPServerDisconnected
>>     >> 这个异常没办法捕获到,虽然我的程序里有这个异常处理子句。
>>     >> 我该怎么处理这个异常?
>>     >>
>>     >> _______________________________________________
>>     >> python-chinese
>>     >> Post: send python-chinese在lists.python.cn
>>     python-chinese在lists.python.cn>
>>     >> Subscribe: send subscribe to
>>     python-chinese-request在lists.python.cn
>>     python-chinese-request在lists.python.cn>
>>     >> Unsubscribe: send unsubscribe to
>>     python-chinese-request在lists.python.cn
>>     python-chinese-request在lists.python.cn>
>>     >> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>     >>
>>     >
>>     > = = = = = = = = = = = = = = = = = = = =
>>     >
>>     >
>>     > 致
>>     > 礼!
>>     >
>>     >
>>     > 赵威
>>     > zhaowei在pythonid.com zhaowei在pythonid.com>
>>     > 2007-12-12
>>     >
>>     > _______________________________________________
>>     > python-chinese
>>     > Post: send python-chinese在lists.python.cn
>>     python-chinese在lists.python.cn>
>>     > Subscribe: send subscribe to
>>     python-chinese-request在lists.python.cn
>>     python-chinese-request在lists.python.cn>
>>     > Unsubscribe: send unsubscribe to
>>     python-chinese-request在lists.python.cn
>>     python-chinese-request在lists.python.cn>
>>     > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>
>>     _______________________________________________
>>     python-chinese
>>     Post: send python-chinese在lists.python.cn
>>     python-chinese在lists.python.cn>
>>     Subscribe: send subscribe to
>>     python-chinese-request在lists.python.cn
>>     python-chinese-request在lists.python.cn>
>>     Unsubscribe: send unsubscribe to
>>     python-chinese-request在lists.python.cn
>>     python-chinese-request在lists.python.cn>
>>     Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>
>>
>> ----------------------------------------------------------------------
>> --
>>
>> _______________________________________________
>> python-chinese
>> Post: send python-chinese在lists.python.cn
>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>> Unsubscribe: send unsubscribe to  
>> python-chinese-request在lists.python.cn
>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>     
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月14日 星期五 11:57

Romit m_list在126.com
星期五 十二月 14 11:57:29 HKT 2007

同样的代码片断在文本模式下跑不存在问题,可是一放到pygtk的环境里就频繁报
错, 搞不懂啊。

Romit 写道:
> 对,就是这个意思,我想能捕获服务器主动断开连接这个异常,我的程序的灵活性
> 就增强了。
> GuoYao 写道:
>   
>> 他的意思好像就是无法捕获服务器主动断开连接 这个异常。
>>
>> -----Original Message-----
>> From: python-chinese-bounces在lists.python.cn
>> [mailto:python-chinese-bounces在lists.python.cn] On Behalf Of Romit
>> Sent: 2007年12月14日 9:42
>> To: python-chinese在lists.python.cn
>> Subject: Re: [python-chinese] smtplib级联异常
>>
>> 126是32份,如意信箱又是一个标准,每家的标准都不一样的。所以我的想法是检
>> 测到smtpserverdisconnected后休眠10分钟后,再发送,这样程序的适应性会比较强。
>>
>> @@ 写道:
>>   
>>     
>>> 如果你确认发32就会触发反垃圾邮件。
>>> 那就每10分钟发31封好了。。。
>>>
>>> On 12/12/07, *Romit* <m_list在126.com m_list在126.com>> wrote:
>>>
>>>     确实是反垃圾邮件的问题,该企业会在月末向员工发送业绩、工资等信息,
>>>     所以发
>>>     送邮件量会比较大,我想在邮件服务器禁止发送后,程序自动等待10分钟后
>>>     重试,
>>>     但是每次SMTP服务器拒绝以后,随后会自动断开连接,你帮忙看一下程序存
>>>     在什么
>>>     问题。
>>>     for a in mbl:
>>>
>>>     
>>> subject=self.mngCltXML.get_widget('entry8').get_text().encode('gb2312'
>>> )
>>>
>>>
>>>     
>>>       
>> text=self.mngCltXML.get_widget('textview1').get_buffer().get_text(self.mngCl
>> tXML.get_widget
>>   
>> ('textview1').get_buffer().get_start_iter(),self.mngCltXML.get_widget('textv
>> iew1').get_buffer().get_end_iter()).encode('gb2312')
>>   
>>     
>>>     msg=MIMEText(text,_subtype='plain',_charset='GB2312')
>>>
>>>     msg['Subject']=subject
>>>     msg['From']=conf['user']
>>>     msg['To']=str(a)+'@sx.133165.com <http://sx.133165.com>'
>>>
>>>     try:
>>>     server=smtplib.SMTP(conf['host'],conf['port'])
>>>     server.set_debuglevel(0)
>>>     except smtplib.SMTPException:
>>>
>>>     
>>> cid_except=self.mngCltXML.get_widget('statusbar1').get_context_id('Bas
>>> e
>>>
>>>     exception class for all exceptions raised by this module.')
>>>
>>>     self.mngCltXML.get_widget('statusbar1').push(cid_except,u'请更换信
>>>     箱,服
>>>     务器拒绝')
>>>     time.sleep(50)
>>>     self.mngCltXML.get_widget ('statusbar1').pop(cid_except)
>>>     except smtplib.SMTPServerDisconnected:
>>>
>>>
>>>     
>>>       
>> cid_sdiscn=self.mngCltXML.get_widget('statusbar1').get_context_id('Server
>>   
>>     
>>>     disconnectiod')
>>>
>>>     self.mngCltXML.get_widget ('statusbar1').pusb(cid_sdiscn,u'服务器
>>>     连接中断')
>>>     time.sleep(5)
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_sdiscn)
>>>     except smtplib.SMTPResponseException :
>>>
>>>     cid_rsp=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
>>>     class for all exceptions that include an SMTP error code. These
>>>     exceptions are generated in some instances when the SMTP server
>>>     returns
>>>     an error code. The error code is stored in the smtp_code attribute of
>>>     the error, and the smtp_error attribute is set to the error message.')
>>>     self.mngCltXML.get_widget('statusbar1').push(cid_rsp,u'
>>>     服务器响应错误')
>>>     time.sleep(5)
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_rsp)
>>>     except smtplib.SMTPSenderRefused:
>>>
>>>     
>>> cid_srfus=self.mngCltXML.get_widget('statusbar1').get_context_id('Send
>>> er
>>>
>>>     address refused. In addition to the attributes set by on all
>>>     SMTPResponseException exceptions, this sets `sender\' to the
>>>     string that
>>>     the SMTP server refused.')
>>>
>>>     self.mngCltXML.get_widget('statusbar1').push(cid_srfus,u'发件地址
>>>     被拒绝')
>>>     time.sleep(600)
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_srfus)
>>>     except smtplib.SMTPRecipientsRefused:
>>>     #如果收件人不存在,直接跳过
>>>     continue
>>>     except smtplib.SMTPDataError:
>>>
>>>     cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>>     server replied with an unexpected error code (other than a refusal
>>>     of a
>>>     recipient).')
>>>     self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
>>>     服务器返回错误')
>>>     time.sleep(5)
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>>>     except smtplib.SMTPConnectError:
>>>
>>>     cid_conn=self.mngCltXML.get_widget('statusbar1').get_context_id('Error
>>>     occurred during establishment of a connection with the server.')
>>>     self.mngCltXML.get_widget ('statusbar1').push(cid_conn,u'
>>>     与服务器连接错误,请更换信箱')
>>>     time.sleep(50)
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_conn)
>>>     except smtplib.SMTPHeloError :
>>>
>>>     cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>>     server didn\'t reply properly to the "HELO" greeting.')
>>>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>>>     服务器未正确相应')
>>>     time.sleep(5)
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>>>
>>>
>>>     try:
>>>     server.login(conf['user'],conf['passwd'])
>>>     except smtplib.SMTPAuthenticationError:
>>>
>>>     cid_auth=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>>     server didn\'t accept the username/password combination.')
>>>     self.mngCltXML.get_widget('statusbar1').push(cid_auth,u'
>>>     用户名或者密码错误,请在SMTP 设置输入正确的用户和密码')
>>>     time.sleep(5)
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_auth)
>>>     except smtplib.SMTPHeloError:
>>>
>>>     cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>>     server didn\'t reply properly to the "HELO" greeting.')
>>>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>>>     服务器未正确相应')
>>>     time.sleep(5)
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>>>     except smtplib.SMTPError :
>>>
>>>     cid_err=self.mngCltXML.get_widget('statusbar1').get_context_id('No
>>>     suitable authentication method was found')
>>>     mngCltXML.get_widget('statusbar1').push(cid_err,u'验证方
>>>     法不匹配')
>>>     break
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_err)
>>>
>>>
>>>     try:
>>>     server.sendmail(conf['user'],
>>>     str(a[0])+'@ sx.133165.com <http://sx.133165.com>',msg.as_string())
>>>     except smtplib.SMTPRecipientsRefused:
>>>     #如果收件人不存在,直接跳过
>>>     continue
>>>     except smtplib.SMTPHeloError:
>>>
>>>     cid_helo=self.mngCltXML.get_widget ('statusbar1').get_context_id('The
>>>     server didn\'t reply properly to the "HELO" greeting.')
>>>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>>>     服务器未正确相应')
>>>     time.sleep(5)
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>>>     except smtplib.SMTPSenderRefused:
>>>     # 发件地址被拒绝通常是由于发送大量电子邮件爱你导致,所以
>>>     休眠一段时间后重复发送
>>>     server.close()
>>>     time.sleep(600)
>>>     server=smtplib.SMTP(conf['host'],conf['port'])
>>>     server.server.login(conf['user'],conf['passwd'])
>>>
>>>     except smtplib.SMTPDataError:
>>>
>>>     cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>>     server replied with an unexpected error code (other than a refusal
>>>     of a
>>>     recipient).')
>>>     self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
>>>     服务器返回错误')
>>>     time.sleep(5)
>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>>>
>>>     server.quit()
>>>
>>>
>>>     赵威 写道:
>>>     > Romit,您好!
>>>     >
>>>     > 又是遇到反垃圾邮件了...
>>>     > 异常可以捕获到的,应该是你捕获的地方不对
>>>     >
>>>     > ======= 2007-12-09 12:28:52 您在来信中写道:=======
>>>     >
>>>     >
>>>     >> 我为某企业写了一个向该企业员工群发电子邮件的程序,使用的是
>>>     smtplib。在通
>>>     >> 过smtp协议迭代群发邮件的时候,特别是连续发送超过32份的时候,
>>>     smtp服务器拒
>>>     >> 绝我发送请求的时候,smtplib通常会抛出一个异常:
>>>     >> smtplib.SMTPException
>>>     >> 紧跟着是另外一个异常:
>>>     >> smtplib.SMTPServerDisconnected
>>>     >> 这个异常没办法捕获到,虽然我的程序里有这个异常处理子句。
>>>     >> 我该怎么处理这个异常?
>>>     >>
>>>     >> _______________________________________________
>>>     >> python-chinese
>>>     >> Post: send python-chinese在lists.python.cn
>>>     python-chinese在lists.python.cn>
>>>     >> Subscribe: send subscribe to
>>>     python-chinese-request在lists.python.cn
>>>     python-chinese-request在lists.python.cn>
>>>     >> Unsubscribe: send unsubscribe to
>>>     python-chinese-request在lists.python.cn
>>>     python-chinese-request在lists.python.cn>
>>>     >> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>     >>
>>>     >
>>>     > = = = = = = = = = = = = = = = = = = = =
>>>     >
>>>     >
>>>     > 致
>>>     > 礼!
>>>     >
>>>     >
>>>     > 赵威
>>>     > zhaowei在pythonid.com zhaowei在pythonid.com>
>>>     > 2007-12-12
>>>     >
>>>     > _______________________________________________
>>>     > python-chinese
>>>     > Post: send python-chinese在lists.python.cn
>>>     python-chinese在lists.python.cn>
>>>     > Subscribe: send subscribe to
>>>     python-chinese-request在lists.python.cn
>>>     python-chinese-request在lists.python.cn>
>>>     > Unsubscribe: send unsubscribe to
>>>     python-chinese-request在lists.python.cn
>>>     python-chinese-request在lists.python.cn>
>>>     > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>
>>>     _______________________________________________
>>>     python-chinese
>>>     Post: send python-chinese在lists.python.cn
>>>     python-chinese在lists.python.cn>
>>>     Subscribe: send subscribe to
>>>     python-chinese-request在lists.python.cn
>>>     python-chinese-request在lists.python.cn>
>>>     Unsubscribe: send unsubscribe to
>>>     python-chinese-request在lists.python.cn
>>>     python-chinese-request在lists.python.cn>
>>>     Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>
>>>
>>> ----------------------------------------------------------------------
>>> --
>>>
>>> _______________________________________________
>>> python-chinese
>>> Post: send python-chinese在lists.python.cn
>>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>>> Unsubscribe: send unsubscribe to  
>>> python-chinese-request在lists.python.cn
>>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>     
>>>       
>> _______________________________________________
>> python-chinese
>> Post: send python-chinese在lists.python.cn
>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>
>> _______________________________________________
>> python-chinese
>> Post: send python-chinese在lists.python.cn
>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>     
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月14日 星期五 12:42

Romit m_list在126.com
星期五 十二月 14 12:42:00 HKT 2007

感谢大家的支持,今天中午终于捕获到了这个异常的错误,原因是我导入了两个模块
from datetime import *
import time
导致名称冲突:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
299
<-----------开始发送邮件----------------->
发送:1/299份邮件
Traceback (most recent call last):
  File "F:\复件 TIENS R3.2.1\TIENS.py", line 148, in send
    self.sendMail()
  File "F:\复件 TIENS R3.2.1\TIENS.py", line 255, in sendMail
    time.sleep(600)
AttributeError: type object 'datetime.time' has no attribute 'sleep'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Romit 写道:
> 同样的代码片断在文本模式下跑不存在问题,可是一放到pygtk的环境里就频繁报
> 错, 搞不懂啊。
>
> Romit 写道:
>   
>> 对,就是这个意思,我想能捕获服务器主动断开连接这个异常,我的程序的灵活性
>> 就增强了。
>> GuoYao 写道:
>>   
>>     
>>> 他的意思好像就是无法捕获服务器主动断开连接 这个异常。
>>>
>>> -----Original Message-----
>>> From: python-chinese-bounces在lists.python.cn
>>> [mailto:python-chinese-bounces在lists.python.cn] On Behalf Of Romit
>>> Sent: 2007年12月14日 9:42
>>> To: python-chinese在lists.python.cn
>>> Subject: Re: [python-chinese] smtplib级联异常
>>>
>>> 126是32份,如意信箱又是一个标准,每家的标准都不一样的。所以我的想法是检
>>> 测到smtpserverdisconnected后休眠10分钟后,再发送,这样程序的适应性会比较强。
>>>
>>> @@ 写道:
>>>   
>>>     
>>>       
>>>> 如果你确认发32就会触发反垃圾邮件。
>>>> 那就每10分钟发31封好了。。。
>>>>
>>>> On 12/12/07, *Romit* <m_list在126.com m_list在126.com>> wrote:
>>>>
>>>>     确实是反垃圾邮件的问题,该企业会在月末向员工发送业绩、工资等信息,
>>>>     所以发
>>>>     送邮件量会比较大,我想在邮件服务器禁止发送后,程序自动等待10分钟后
>>>>     重试,
>>>>     但是每次SMTP服务器拒绝以后,随后会自动断开连接,你帮忙看一下程序存
>>>>     在什么
>>>>     问题。
>>>>     for a in mbl:
>>>>
>>>>     
>>>> subject=self.mngCltXML.get_widget('entry8').get_text().encode('gb2312'
>>>> )
>>>>
>>>>
>>>>     
>>>>       
>>>>         
>>> text=self.mngCltXML.get_widget('textview1').get_buffer().get_text(self.mngCl
>>> tXML.get_widget
>>>   
>>> ('textview1').get_buffer().get_start_iter(),self.mngCltXML.get_widget('textv
>>> iew1').get_buffer().get_end_iter()).encode('gb2312')
>>>   
>>>     
>>>       
>>>>     msg=MIMEText(text,_subtype='plain',_charset='GB2312')
>>>>
>>>>     msg['Subject']=subject
>>>>     msg['From']=conf['user']
>>>>     msg['To']=str(a)+'@sx.133165.com <http://sx.133165.com>'
>>>>
>>>>     try:
>>>>     server=smtplib.SMTP(conf['host'],conf['port'])
>>>>     server.set_debuglevel(0)
>>>>     except smtplib.SMTPException:
>>>>
>>>>     
>>>> cid_except=self.mngCltXML.get_widget('statusbar1').get_context_id('Bas
>>>> e
>>>>
>>>>     exception class for all exceptions raised by this module.')
>>>>
>>>>     self.mngCltXML.get_widget('statusbar1').push(cid_except,u'请更换信
>>>>     箱,服
>>>>     务器拒绝')
>>>>     time.sleep(50)
>>>>     self.mngCltXML.get_widget ('statusbar1').pop(cid_except)
>>>>     except smtplib.SMTPServerDisconnected:
>>>>
>>>>
>>>>     
>>>>       
>>>>         
>>> cid_sdiscn=self.mngCltXML.get_widget('statusbar1').get_context_id('Server
>>>   
>>>     
>>>       
>>>>     disconnectiod')
>>>>
>>>>     self.mngCltXML.get_widget ('statusbar1').pusb(cid_sdiscn,u'服务器
>>>>     连接中断')
>>>>     time.sleep(5)
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_sdiscn)
>>>>     except smtplib.SMTPResponseException :
>>>>
>>>>     cid_rsp=self.mngCltXML.get_widget('statusbar1').get_context_id('Base
>>>>     class for all exceptions that include an SMTP error code. These
>>>>     exceptions are generated in some instances when the SMTP server
>>>>     returns
>>>>     an error code. The error code is stored in the smtp_code attribute of
>>>>     the error, and the smtp_error attribute is set to the error message.')
>>>>     self.mngCltXML.get_widget('statusbar1').push(cid_rsp,u'
>>>>     服务器响应错误')
>>>>     time.sleep(5)
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_rsp)
>>>>     except smtplib.SMTPSenderRefused:
>>>>
>>>>     
>>>> cid_srfus=self.mngCltXML.get_widget('statusbar1').get_context_id('Send
>>>> er
>>>>
>>>>     address refused. In addition to the attributes set by on all
>>>>     SMTPResponseException exceptions, this sets `sender\' to the
>>>>     string that
>>>>     the SMTP server refused.')
>>>>
>>>>     self.mngCltXML.get_widget('statusbar1').push(cid_srfus,u'发件地址
>>>>     被拒绝')
>>>>     time.sleep(600)
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_srfus)
>>>>     except smtplib.SMTPRecipientsRefused:
>>>>     #如果收件人不存在,直接跳过
>>>>     continue
>>>>     except smtplib.SMTPDataError:
>>>>
>>>>     cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>>>     server replied with an unexpected error code (other than a refusal
>>>>     of a
>>>>     recipient).')
>>>>     self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
>>>>     服务器返回错误')
>>>>     time.sleep(5)
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>>>>     except smtplib.SMTPConnectError:
>>>>
>>>>     cid_conn=self.mngCltXML.get_widget('statusbar1').get_context_id('Error
>>>>     occurred during establishment of a connection with the server.')
>>>>     self.mngCltXML.get_widget ('statusbar1').push(cid_conn,u'
>>>>     与服务器连接错误,请更换信箱')
>>>>     time.sleep(50)
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_conn)
>>>>     except smtplib.SMTPHeloError :
>>>>
>>>>     cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>>>     server didn\'t reply properly to the "HELO" greeting.')
>>>>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>>>>     服务器未正确相应')
>>>>     time.sleep(5)
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>>>>
>>>>
>>>>     try:
>>>>     server.login(conf['user'],conf['passwd'])
>>>>     except smtplib.SMTPAuthenticationError:
>>>>
>>>>     cid_auth=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>>>     server didn\'t accept the username/password combination.')
>>>>     self.mngCltXML.get_widget('statusbar1').push(cid_auth,u'
>>>>     用户名或者密码错误,请在SMTP 设置输入正确的用户和密码')
>>>>     time.sleep(5)
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_auth)
>>>>     except smtplib.SMTPHeloError:
>>>>
>>>>     cid_helo=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>>>     server didn\'t reply properly to the "HELO" greeting.')
>>>>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>>>>     服务器未正确相应')
>>>>     time.sleep(5)
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>>>>     except smtplib.SMTPError :
>>>>
>>>>     cid_err=self.mngCltXML.get_widget('statusbar1').get_context_id('No
>>>>     suitable authentication method was found')
>>>>     mngCltXML.get_widget('statusbar1').push(cid_err,u'验证方
>>>>     法不匹配')
>>>>     break
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_err)
>>>>
>>>>
>>>>     try:
>>>>     server.sendmail(conf['user'],
>>>>     str(a[0])+'@ sx.133165.com <http://sx.133165.com>',msg.as_string())
>>>>     except smtplib.SMTPRecipientsRefused:
>>>>     #如果收件人不存在,直接跳过
>>>>     continue
>>>>     except smtplib.SMTPHeloError:
>>>>
>>>>     cid_helo=self.mngCltXML.get_widget ('statusbar1').get_context_id('The
>>>>     server didn\'t reply properly to the "HELO" greeting.')
>>>>     self.mngCltXML.get_widget('statusbar1').push(cid_helo,u'
>>>>     服务器未正确相应')
>>>>     time.sleep(5)
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_helo)
>>>>     except smtplib.SMTPSenderRefused:
>>>>     # 发件地址被拒绝通常是由于发送大量电子邮件爱你导致,所以
>>>>     休眠一段时间后重复发送
>>>>     server.close()
>>>>     time.sleep(600)
>>>>     server=smtplib.SMTP(conf['host'],conf['port'])
>>>>     server.server.login(conf['user'],conf['passwd'])
>>>>
>>>>     except smtplib.SMTPDataError:
>>>>
>>>>     cid_data=self.mngCltXML.get_widget('statusbar1').get_context_id('The
>>>>     server replied with an unexpected error code (other than a refusal
>>>>     of a
>>>>     recipient).')
>>>>     self.mngCltXML.get_widget('statusbar1').push(cid_data,u'
>>>>     服务器返回错误')
>>>>     time.sleep(5)
>>>>     self.mngCltXML.get_widget('statusbar1').pop(cid_data)
>>>>
>>>>     server.quit()
>>>>
>>>>
>>>>     赵威 写道:
>>>>     > Romit,您好!
>>>>     >
>>>>     > 又是遇到反垃圾邮件了...
>>>>     > 异常可以捕获到的,应该是你捕获的地方不对
>>>>     >
>>>>     > ======= 2007-12-09 12:28:52 您在来信中写道:=======
>>>>     >
>>>>     >
>>>>     >> 我为某企业写了一个向该企业员工群发电子邮件的程序,使用的是
>>>>     smtplib。在通
>>>>     >> 过smtp协议迭代群发邮件的时候,特别是连续发送超过32份的时候,
>>>>     smtp服务器拒
>>>>     >> 绝我发送请求的时候,smtplib通常会抛出一个异常:
>>>>     >> smtplib.SMTPException
>>>>     >> 紧跟着是另外一个异常:
>>>>     >> smtplib.SMTPServerDisconnected
>>>>     >> 这个异常没办法捕获到,虽然我的程序里有这个异常处理子句。
>>>>     >> 我该怎么处理这个异常?
>>>>     >>
>>>>     >> _______________________________________________
>>>>     >> python-chinese
>>>>     >> Post: send python-chinese在lists.python.cn
>>>>     python-chinese在lists.python.cn>
>>>>     >> Subscribe: send subscribe to
>>>>     python-chinese-request在lists.python.cn
>>>>     python-chinese-request在lists.python.cn>
>>>>     >> Unsubscribe: send unsubscribe to
>>>>     python-chinese-request在lists.python.cn
>>>>     python-chinese-request在lists.python.cn>
>>>>     >> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>>     >>
>>>>     >
>>>>     > = = = = = = = = = = = = = = = = = = = =
>>>>     >
>>>>     >
>>>>     > 致
>>>>     > 礼!
>>>>     >
>>>>     >
>>>>     > 赵威
>>>>     > zhaowei在pythonid.com zhaowei在pythonid.com>
>>>>     > 2007-12-12
>>>>     >
>>>>     > _______________________________________________
>>>>     > python-chinese
>>>>     > Post: send python-chinese在lists.python.cn
>>>>     python-chinese在lists.python.cn>
>>>>     > Subscribe: send subscribe to
>>>>     python-chinese-request在lists.python.cn
>>>>     python-chinese-request在lists.python.cn>
>>>>     > Unsubscribe: send unsubscribe to
>>>>     python-chinese-request在lists.python.cn
>>>>     python-chinese-request在lists.python.cn>
>>>>     > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>>
>>>>     _______________________________________________
>>>>     python-chinese
>>>>     Post: send python-chinese在lists.python.cn
>>>>     python-chinese在lists.python.cn>
>>>>     Subscribe: send subscribe to
>>>>     python-chinese-request在lists.python.cn
>>>>     python-chinese-request在lists.python.cn>
>>>>     Unsubscribe: send unsubscribe to
>>>>     python-chinese-request在lists.python.cn
>>>>     python-chinese-request在lists.python.cn>
>>>>     Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>>
>>>>
>>>> ----------------------------------------------------------------------
>>>> --
>>>>
>>>> _______________________________________________
>>>> python-chinese
>>>> Post: send python-chinese在lists.python.cn
>>>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>>>> Unsubscribe: send unsubscribe to  
>>>> python-chinese-request在lists.python.cn
>>>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>>     
>>>>       
>>>>         
>>> _______________________________________________
>>> python-chinese
>>> Post: send python-chinese在lists.python.cn
>>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>
>>> _______________________________________________
>>> python-chinese
>>> Post: send python-chinese在lists.python.cn
>>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>     
>>>       
>> _______________________________________________
>> python-chinese
>> Post: send python-chinese在lists.python.cn
>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>     
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月14日 星期五 13:12

Leo Jay python.leojay在gmail.com
星期五 十二月 14 13:12:14 HKT 2007

On Dec 14, 2007 12:42 PM, Romit <m_list在126.com> wrote:
> 感谢大家的支持,今天中午终于捕获到了这个异常的错误,原因是我导入了两个模块
> from datetime import *
> import time
> 导致名称冲突:
>

千万不要使用from XXX import *的写法。
这样会造成名字空间污染,编译型的语言了不起编译出错。
解释型的语言则是相当要命的。

你要用什么就import什么,如:
from datetime import datetime
from time import sleep
或是
import datetime
import time

-- 
Best Regards,
Leo Jay

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号