Merge pull request #452 from gwasser/get_email

Ensure that local files are deleted after processing
This commit is contained in:
Jonathan Barratt 2016-11-12 12:02:48 +07:00 committed by GitHub
commit 07f7489e2c
2 changed files with 8 additions and 1 deletions

View File

@ -102,3 +102,10 @@ Adding To Your Django Project
9. Load initial e-mail templates, otherwise you will not be able to send e-mail:: 9. Load initial e-mail templates, otherwise you will not be able to send e-mail::
python manage.py loaddata emailtemplate.json python manage.py loaddata emailtemplate.json
10. If you intend on using local mail directories for processing email into tickets, be sure to create the mail directory before adding it to the queue in the Django administrator interface. The default mail directory is ``/var/lib/mail/helpdesk/``. Ensure that the directory has appropriate permissions so that your Django/web server instance may read and write files from this directory.
Note that by default, any mail files placed in your local directory will be permanently deleted after being successfully processed. It is strongly recommended that you take further steps to save emails if you wish to retain backups.
Also, be aware that if a disk error occurs and the local file is not deleted, the mail may be processed multiple times and generate duplicate tickets until the file is removed. It is recommended to monitor log files for ERRORS when a file is unable to be deleted.

View File

@ -239,7 +239,7 @@ def process_queue(q, logger):
if ticket: if ticket:
logger.info("Successfully processed message %s, ticket/comment created." % str(m)) logger.info("Successfully processed message %s, ticket/comment created." % str(m))
try: try:
# unlink(m) #delete message file if ticket was successful unlink(m) # delete message file if ticket was successful
logger.info("Successfully deleted message %s." % str(m)) logger.info("Successfully deleted message %s." % str(m))
except: except:
logger.error("Unable to delete message %s." % str(m)) logger.error("Unable to delete message %s." % str(m))