forked from mirror/django-mailbox
Adding gmail to the mailbox types
and adding the type to models.py
This commit is contained in:
parent
cc4e72305d
commit
677e420dec
2 changed files with 23 additions and 1 deletions
|
|
@ -15,7 +15,7 @@ from django.core.files.base import ContentFile
|
|||
from django.db import models
|
||||
from django_mailbox.transports import Pop3Transport, ImapTransport,\
|
||||
MaildirTransport, MboxTransport, BabylTransport, MHTransport, \
|
||||
MMDFTransport
|
||||
MMDFTransport, GmailImapTransport
|
||||
from django_mailbox.signals import message_received
|
||||
import six
|
||||
from six.moves.urllib.parse import parse_qs, unquote, urlparse
|
||||
|
|
@ -168,6 +168,14 @@ class Mailbox(models.Model):
|
|||
archive=self.archive
|
||||
)
|
||||
conn.connect(self.username, self.password)
|
||||
elif self.type == 'gmail':
|
||||
conn = GmailImapTransport(
|
||||
self.location,
|
||||
port=self.port if self.port else None,
|
||||
ssl=True,
|
||||
archive=self.archive
|
||||
)
|
||||
conn.connect(self.username, self.password)
|
||||
elif self.type == 'pop3':
|
||||
conn = Pop3Transport(
|
||||
self.location,
|
||||
|
|
|
|||
|
|
@ -61,6 +61,20 @@ would enter the following as your URI::
|
|||
|
||||
imap+ssl://youremailaddress%40gmail.com:1234@imap.gmail.com?archive=Archived
|
||||
|
||||
Gmail IMAP with Oauth2 authentication
|
||||
-------------------------------------
|
||||
|
||||
Gmail supports using oauth2 for authentication_ which is more secure.
|
||||
To handle the handshake and storing the credentials, use python-social-auth_.
|
||||
|
||||
.. _authentication: https://developers.google.com/gmail/xoauth2_protocol
|
||||
.. _python-social-auth: http://psa.matiasaguirre.net/
|
||||
|
||||
The Gmail Mailbox is also a regular IMAP mailbox, but the password will be ignored if oauth2 succeeds. It can fall back to password as needed.
|
||||
Build your URI accordingly::
|
||||
|
||||
gmail+ssl://youremailaddress%40gmail.com:oauth2@imap.gmail.com?archive=Archived
|
||||
|
||||
|
||||
Local File-based Mailboxes
|
||||
--------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue