Enrique Verdes wrote:
> 
> ---snip---
> def mail(to='', who=''):
>     sender='[EMAIL PROTECTED]'
>     message = email.Message.Message()
>     message["To"]      = to
>     message["From"]    = sender
>     message["Date"]    = email.Utils.formatdate(localtime=1)
>     message["Subject"] = 'Aviso de e-mail con virus'
>     text=who + "Le envio un mail que fue rechazado por el antivirus en 
> el servidor"

I'd use string formatting instead of concatenation:

     text = "You received a message from '%s', which contained a virus." % who

>     message.set_payload(text)
>     mailServer = smtplib.SMTP('localhost:25')
>     mailServer.sendmail(sender, to, message.as_string())
>     mailServer.quit()
> 
> def doFilter(bodyFile, controlFileList):
>     # check for viruses
>     try:
>         pyclamd.init_unix_socket('/var/run/clamav/clamd.socket')
>         avresult = pyclamd.contscan_file(bodyFile)
> 
>     except Exception, e:
>         return "554 " + str(e)
> 
>     if avresult == None:
>         return ''
> 
>     if avresult.has_key(bodyFile):
>         mail(courier.control.getRecipients(controlFileList), 
> courier.control.getSender(controlFileList))
>         return "554 %s was detected. Abort!" % avresult[bodyFile]

Right there, you want:

     if avresult.has_key(bodyFile):
         sender = courier.control.getSender(controlFileList)
         for recipient in courier.control.getRecipients(controlFileList):
             mail(recipient, sender)
         return "554 %s was detected. Abort!" % avresult[bodyFile]



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to