mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Merge pull request #293 from pfouque/resend_poor_type_checking
Improve Resend documentation and checks
This commit is contained in:
commit
8992babec6
5 changed files with 34 additions and 21 deletions
|
|
@ -300,7 +300,7 @@ class Mailbox(models.Model):
|
||||||
new = EmailMessage()
|
new = EmailMessage()
|
||||||
if (
|
if (
|
||||||
msg.is_multipart()
|
msg.is_multipart()
|
||||||
and not 'attachment' in msg.get('Content-Disposition', '')
|
and 'attachment' not in msg.get('Content-Disposition', '')
|
||||||
):
|
):
|
||||||
for header, value in msg.items():
|
for header, value in msg.items():
|
||||||
new[header] = value
|
new[header] = value
|
||||||
|
|
@ -647,14 +647,24 @@ class Message(models.Model):
|
||||||
return addresses
|
return addresses
|
||||||
|
|
||||||
def reply(self, message):
|
def reply(self, message):
|
||||||
"""Sends a message as a reply to this message instance.
|
"""Sends an EmailMessage as a reply to this message instance::
|
||||||
|
|
||||||
|
from django.core.mail import EmailMessage
|
||||||
|
|
||||||
|
message.reply(
|
||||||
|
EmailMessage(subject="pong", body="pongpong")
|
||||||
|
)
|
||||||
|
|
||||||
Although Django's e-mail processing will set both Message-ID
|
Although Django's e-mail processing will set both Message-ID
|
||||||
and Date upon generating the e-mail message, we will not be able
|
and Date upon generating the e-mail message, we will not be able
|
||||||
to retrieve that information through normal channels, so we must
|
to retrieve that information through normal channels, so we must
|
||||||
pre-set it.
|
pre-set it.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from django.core.mail import EmailMessage as DjangoEmailMessage
|
||||||
|
|
||||||
|
if not isinstance(message, DjangoEmailMessage):
|
||||||
|
raise ValueError('Message must be an instance of django.core.mail.EmailMessage')
|
||||||
|
|
||||||
if not message.from_email:
|
if not message.from_email:
|
||||||
if self.mailbox.from_email:
|
if self.mailbox.from_email:
|
||||||
message.from_email = self.mailbox.from_email
|
message.from_email = self.mailbox.from_email
|
||||||
|
|
@ -888,7 +898,6 @@ class MessageAttachment(models.Model):
|
||||||
return f'{self.get_filename()}: {self.document.url}'
|
return f'{self.get_filename()}: {self.document.url}'
|
||||||
return self.get_filename()
|
return self.get_filename()
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('Message attachment')
|
verbose_name = _('Message attachment')
|
||||||
verbose_name_plural = _('Message attachments')
|
verbose_name_plural = _('Message attachments')
|
||||||
|
|
|
||||||
|
|
@ -345,6 +345,9 @@ class TestProcessEmail(EmailMessageTestCase):
|
||||||
)
|
)
|
||||||
msg = self.mailbox.record_outgoing_message(email_object.message())
|
msg = self.mailbox.record_outgoing_message(email_object.message())
|
||||||
|
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
msg.reply(Message(subject="ping", body="pong"))
|
||||||
|
|
||||||
self.assertTrue(msg.outgoing)
|
self.assertTrue(msg.outgoing)
|
||||||
|
|
||||||
actual_from = 'username@example.com'
|
actual_from = 'username@example.com'
|
||||||
|
|
@ -439,7 +442,7 @@ class TestProcessEmail(EmailMessageTestCase):
|
||||||
|
|
||||||
msg = self.mailbox.process_incoming_message(message)
|
msg = self.mailbox.process_incoming_message(message)
|
||||||
|
|
||||||
actual_email_object = msg.get_email_object()
|
_actual_email_object = msg.get_email_object()
|
||||||
|
|
||||||
self.assertTrue(msg.eml.name.endswith('.eml.gz'))
|
self.assertTrue(msg.eml.name.endswith('.eml.gz'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,20 @@ POP3 and IMAP as well as local file-based mailboxes.
|
||||||
|
|
||||||
.. table:: 'Protocol' Options
|
.. table:: 'Protocol' Options
|
||||||
|
|
||||||
============ ================ ====================================================================================================================================================================
|
================ ================ ====================================================================================================================================================================
|
||||||
Mailbox Type 'Protocol':// Notes
|
Mailbox Type 'Protocol':// Notes
|
||||||
============ ================ ====================================================================================================================================================================
|
================ ================ ====================================================================================================================================================================
|
||||||
POP3 ``pop3://`` Can also specify SSL with ``pop3+ssl://``
|
POP3 ``pop3://`` Can also specify SSL with ``pop3+ssl://``
|
||||||
IMAP ``imap://`` Can also specify SSL with ``imap+ssl://`` or STARTTLS with ``imap+tls``; additional configuration is also possible: see :ref:`pop3-and-imap-mailboxes` for details.
|
IMAP ``imap://`` Can also specify SSL with ``imap+ssl://`` or STARTTLS with ``imap+tls``; additional configuration is also possible: see :ref:`pop3-and-imap-mailboxes` for details.
|
||||||
Gmail IMAP ``gmail+ssl://`` Uses OAuth authentication for Gmail's IMAP transport. See :ref:`gmail-oauth` for details.
|
Gmail IMAP ``gmail+ssl://`` Uses OAuth authentication for Gmail's IMAP transport. See :ref:`gmail-oauth` for details.
|
||||||
Office365 API``office365://`` Uses OAuth authentication for Office365 API transport. See :ref:`office365-oauth` for details.
|
Office365 API ``office365://`` Uses OAuth authentication for Office365 API transport. See :ref:`office365-oauth` for details.
|
||||||
Maildir ``maildir://``
|
Maildir ``maildir://`` *empty*
|
||||||
Mbox ``mbox://``
|
Mbox ``mbox://`` *empty*
|
||||||
Babyl ``babyl://``
|
Babyl ``babyl://`` *empty*
|
||||||
MH ``mh://``
|
MH ``mh://`` *empty*
|
||||||
MMDF ``mmdf://``
|
MMDF ``mmdf://`` *empty*
|
||||||
Piped Mail *empty* See :ref:`receiving-mail-from-exim4-or-postfix`
|
Piped Mail *empty* See :ref:`receiving-mail-from-exim4-or-postfix`
|
||||||
============ ================ ====================================================================================================================================================================
|
================ ================ ====================================================================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
@ -122,6 +122,7 @@ Build your URI accordingly::
|
||||||
|
|
||||||
|
|
||||||
.. _office365-oauth:
|
.. _office365-oauth:
|
||||||
|
|
||||||
Office 365 API
|
Office 365 API
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue