File: exceptions.rst

package info (click to toggle)
django-anymail 13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,480 kB
  • sloc: python: 27,832; makefile: 132; javascript: 33; sh: 9
file content (73 lines) | stat: -rw-r--r-- 2,862 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
.. _anymail-exceptions:

Exceptions
----------

.. module:: anymail.exceptions

.. exception:: AnymailUnsupportedFeature

    If the email tries to use features that aren't supported by the ESP, the send
    call will raise an :exc:`!AnymailUnsupportedFeature` error, and the message
    won't be sent. See :ref:`unsupported-features`.

    You can disable this exception (ignoring the unsupported features and
    sending the message anyway, without them) by setting
    :setting:`ANYMAIL_IGNORE_UNSUPPORTED_FEATURES` to `True`.


.. exception:: AnymailRecipientsRefused

    Raised when *all* recipients (to, cc, bcc) of a message are invalid or rejected by
    your ESP *at send time.* See :ref:`recipients-refused`.

    You can disable this exception by setting :setting:`ANYMAIL_IGNORE_RECIPIENT_STATUS`
    to `True` in your settings.py, which will cause Anymail to treat any
    non-:exc:`AnymailAPIError` response from your ESP as a successful send.


.. exception:: AnymailAPIError

    If the ESP's API fails or returns an error response, the send call will
    raise an :exc:`!AnymailAPIError`.

    The exception's :attr:`status_code` and :attr:`response` attributes may
    help explain what went wrong. (Tip: you may also be able to check the API log in
    your ESP's dashboard. See :ref:`troubleshooting`.)

    In production, it's not unusual for sends to occasionally fail due to transient
    connectivity problems, ESP maintenance, or other operational issues. Typically
    these failures have a 5xx :attr:`status_code`. See :ref:`transient-errors`
    for suggestions on retrying these failed sends.


.. exception:: AnymailInvalidAddress

    The send call will raise a :exc:`!AnymailInvalidAddress` error if you
    attempt to send a message with invalidly-formatted email addresses in
    the :attr:`from_email` or recipient lists.

    One source of this error can be using a display-name ("real name") containing
    commas or parentheses. Per :rfc:`5322`, you should use double quotes around
    the display-name portion of an email address:

    .. code-block:: python

        # won't work:
        send_mail(from_email='Widgets, Inc. <widgets@example.com>', ...)
        # must use double quotes around display-name containing comma:
        send_mail(from_email='"Widgets, Inc." <widgets@example.com>', ...)


.. exception:: AnymailSerializationError

    The send call will raise a :exc:`!AnymailSerializationError`
    if there are message attributes Anymail doesn't know how to represent
    to your ESP.

    The most common cause of this error is including values other than
    strings and numbers in your :attr:`merge_data` or :attr:`metadata`.
    (E.g., you need to format `Decimal` and `date` data to
    strings before setting them into :attr:`merge_data`.)

    See :ref:`formatting-merge-data` for more information.