Esempio n. 1
0
 def write_mbox(self, msgstr, fromm):
     if self.config.postfilteredmailsmbox == '':
         aprint(
             _("Warning: SavePostFilteredMails activated for this %s PostFilter but no"
               ) % self.filtername, general.RED)
         aprint(_("PostFilteredMailsMBox configured: Won't save the email"),
                general.RED)
         return
     aprint(
         _("Saving message to %s...") % self.config.postfilteredmailsmbox,
         general.RED)
     try:
         mbox = open(self.config.postfilteredmailsmbox, 'a+')
         fcntl.flock(mbox.fileno(), fcntl.LOCK_EX)
         mbox.seek(0, 2)
         (foo, emailaddr) = rfc822.parseaddr(fromm)
         strfromm = 'From %s' % emailaddr + ' ' + general.take_date() + '\n'
         mbox.write(strfromm)
         mbox.write(self.process_mail(msgstr))
         mbox.flush()
         fcntl.flock(mbox.fileno(), fcntl.LOCK_UN)
         mbox.close()
     except IOError, x:
         try:
             fcntl.flock(mbox.fileno(), fcntl.LOCK_UN)
             mbox.close()
         except:
             pass
         aprint(
             _("Sorry, couldn't save the filtered message to %s: %s") %
             (self.config.postfilteredmailsmbox, x), general.RED)
Esempio n. 2
0
 def write_mbox(self, mbox, header, body, fromm):
     try:
             fcntl.flock(mbox.fileno(), fcntl.LOCK_EX)
             mbox.seek(0,2)
             (foo,emailaddr) = rfc822.parseaddr(fromm)
             strfromm = 'From %s' % emailaddr + ' ' + general.take_date() + '\n'
             mbox.write(strfromm)
             if self.__class__.__name__ != "Pop3Server":
                         mbox.write(header)
             if body[:-1] != '\n': body += '\n'
             mbox.write(self.process_body(body))
             mbox.flush()
             fcntl.flock(mbox.fileno(), fcntl.LOCK_UN)
             mbox.close()
     except IOError, x:
             try:
                         fcntl.flock(mbox.fileno(), fcntl.LOCK_UN)
                         mbox.close()
             except:
                         pass
             raise mboxException, _("Failure writing to mbox file '%s' (%s)") % (mbox.name,x)
Esempio n. 3
0
 def write_mbox(self, mbox, header, body, fromm):
     try:
             fcntl.flock(mbox.fileno(), fcntl.LOCK_EX)
             mbox.seek(0,2)
             (foo,emailaddr) = rfc822.parseaddr(fromm)
             strfromm = 'From %s' % emailaddr + ' ' + general.take_date() + '\n'
             mbox.write(strfromm)
             if self.__class__.__name__ != "Pop3Server":
                         mbox.write(header)
             if body[:-1] != '\n': body += '\n'
             mbox.write(self.process_body(body))
             mbox.flush()
             fcntl.flock(mbox.fileno(), fcntl.LOCK_UN)
             mbox.close()
     except IOError, x:
             try:
                         fcntl.flock(mbox.fileno(), fcntl.LOCK_UN)
                         mbox.close()
             except:
                         pass
             raise mboxException, _("Failure writing to mbox file '%s' (%s)") % (mbox.name,x)
Esempio n. 4
0
 def write_mbox(self,msgstr,fromm):    
     if self.config.postfilteredmailsmbox == '':
         aprint(_("Warning: SavePostFilteredMails activated for this %s PostFilter but no") % self.filtername, general.RED)
         aprint(_("PostFilteredMailsMBox configured: Won't save the email"), general.RED)
         return
     aprint(_("Saving message to %s...") % self.config.postfilteredmailsmbox,general.RED)
     try:
         mbox = open(self.config.postfilteredmailsmbox,'a+')
         fcntl.flock(mbox.fileno(), fcntl.LOCK_EX)
         mbox.seek(0,2)
         (foo,emailaddr) = rfc822.parseaddr(fromm)
         strfromm = 'From %s' % emailaddr + ' ' + general.take_date() + '\n'
         mbox.write(strfromm)
         mbox.write(self.process_mail(msgstr))
         mbox.flush()
         fcntl.flock(mbox.fileno(), fcntl.LOCK_UN)
         mbox.close()
     except IOError, x:
         try:
             fcntl.flock(mbox.fileno(), fcntl.LOCK_UN)
             mbox.close()
         except:
             pass
         aprint(_("Sorry, couldn't save the filtered message to %s: %s") % (self.config.postfilteredmailsmbox,x), general.RED)