mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-14 02:41:26 +01:00
added global queue default email settings
This commit is contained in:
parent
537d403d99
commit
164a9f44bb
@ -25,6 +25,7 @@ from django.core.files.base import ContentFile
|
|||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from helpdesk.lib import send_templated_mail, safe_template_context
|
from helpdesk.lib import send_templated_mail, safe_template_context
|
||||||
from helpdesk.models import Queue, Ticket, FollowUp, Attachment, IgnoreEmail
|
from helpdesk.models import Queue, Ticket, FollowUp, Attachment, IgnoreEmail
|
||||||
@ -75,18 +76,22 @@ def process_email(quiet=False):
|
|||||||
def process_queue(q, quiet=False):
|
def process_queue(q, quiet=False):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print "Processing: %s" % q
|
print "Processing: %s" % q
|
||||||
if q.email_box_type == 'pop3':
|
|
||||||
|
email_box_type = settings.QUEUE_EMAIL_BOX_TYPE if settings.QUEUE_EMAIL_BOX_TYPE else q.email_box_type
|
||||||
|
|
||||||
|
if email_box_type == 'pop3':
|
||||||
|
|
||||||
if q.email_box_ssl:
|
if q.email_box_ssl:
|
||||||
if not q.email_box_port: q.email_box_port = 995
|
if not q.email_box_port: q.email_box_port = 995
|
||||||
server = poplib.POP3_SSL(q.email_box_host, int(q.email_box_port))
|
server = poplib.POP3_SSL(q.email_box_host or settings.QUEUE_EMAIL_BOX_HOST, int(q.email_box_port))
|
||||||
else:
|
else:
|
||||||
if not q.email_box_port: q.email_box_port = 110
|
if not q.email_box_port: q.email_box_port = 110
|
||||||
server = poplib.POP3(q.email_box_host, int(q.email_box_port))
|
server = poplib.POP3(q.email_box_host or settings.QUEUE_EMAIL_BOX_HOST, int(q.email_box_port))
|
||||||
|
|
||||||
server.getwelcome()
|
server.getwelcome()
|
||||||
server.user(q.email_box_user)
|
server.user(q.email_box_user or settings.QUEUE_EMAIL_BOX_USER)
|
||||||
server.pass_(q.email_box_pass)
|
server.pass_(q.email_box_pass or settings.QUEUE_EMAIL_BOX_PASSWORD)
|
||||||
|
|
||||||
|
|
||||||
messagesInfo = server.list()[1]
|
messagesInfo = server.list()[1]
|
||||||
|
|
||||||
@ -102,15 +107,15 @@ def process_queue(q, quiet=False):
|
|||||||
|
|
||||||
server.quit()
|
server.quit()
|
||||||
|
|
||||||
elif q.email_box_type == 'imap':
|
elif email_box_type == 'imap':
|
||||||
if q.email_box_ssl:
|
if q.email_box_ssl:
|
||||||
if not q.email_box_port: q.email_box_port = 993
|
if not q.email_box_port: q.email_box_port = 993
|
||||||
server = imaplib.IMAP4_SSL(q.email_box_host, int(q.email_box_port))
|
server = imaplib.IMAP4_SSL(q.email_box_host or settings.QUEUE_EMAIL_BOX_HOST, int(q.email_box_port))
|
||||||
else:
|
else:
|
||||||
if not q.email_box_port: q.email_box_port = 143
|
if not q.email_box_port: q.email_box_port = 143
|
||||||
server = imaplib.IMAP4(q.email_box_host, int(q.email_box_port))
|
server = imaplib.IMAP4(q.email_box_host or settings.QUEUE_EMAIL_BOX_HOST, int(q.email_box_port))
|
||||||
|
|
||||||
server.login(q.email_box_user, q.email_box_pass)
|
server.login(q.email_box_user or settings.QUEUE_EMAIL_BOX_USER, q.email_box_pass or settings.QUEUE_EMAIL_BOX_PASSWORD)
|
||||||
server.select(q.email_box_imap_folder)
|
server.select(q.email_box_imap_folder)
|
||||||
|
|
||||||
status, data = server.search(None, 'NOT', 'DELETED')
|
status, data = server.search(None, 'NOT', 'DELETED')
|
||||||
|
@ -124,3 +124,9 @@ HELPDESK_FOOTER_SHOW_API_LINK = getattr(settings, 'HELPDESK_FOOTER_SHOW_API_LINK
|
|||||||
# show / hide 'change language' link at bottom of page
|
# show / hide 'change language' link at bottom of page
|
||||||
HELPDESK_FOOTER_SHOW_CHANGE_LANGUAGE_LINK = getattr(settings, 'HELPDESK_FOOTER_SHOW_CHANGE_LANGUAGE_LINK', False)
|
HELPDESK_FOOTER_SHOW_CHANGE_LANGUAGE_LINK = getattr(settings, 'HELPDESK_FOOTER_SHOW_CHANGE_LANGUAGE_LINK', False)
|
||||||
|
|
||||||
|
''' email options '''
|
||||||
|
# default Queue email submission settings
|
||||||
|
QUEUE_EMAIL_BOX_TYPE = getattr(settings, 'QUEUE_EMAIL_BOX_TYPE', None)
|
||||||
|
QUEUE_EMAIL_BOX_HOST = getattr(settings, 'QUEUE_EMAIL_BOX_HOST', None)
|
||||||
|
QUEUE_EMAIL_BOX_USER = getattr(settings, 'QUEUE_EMAIL_BOX_USER', None)
|
||||||
|
QUEUE_EMAIL_BOX_PASSWORD = getattr(settings, 'QUEUE_EMAIL_BOX_PASSWORD', None)
|
||||||
|
Loading…
Reference in New Issue
Block a user