Source code for aiosmtplib.errors

from asyncio import TimeoutError
from typing import List


__all__ = (
    "SMTPAuthenticationError",
    "SMTPConnectError",
    "SMTPDataError",
    "SMTPException",
    "SMTPHeloError",
    "SMTPNotSupported",
    "SMTPRecipientRefused",
    "SMTPRecipientsRefused",
    "SMTPResponseException",
    "SMTPSenderRefused",
    "SMTPServerDisconnected",
    "SMTPTimeoutError",
    "SMTPConnectTimeoutError",
    "SMTPReadTimeoutError",
    "SMTPConnectResponseError",
)


[docs] class SMTPException(Exception): """ Base class for all SMTP exceptions. """ def __init__(self, message: str, /) -> None: self.message = message self.args = (message,)
[docs] class SMTPServerDisconnected(SMTPException, ConnectionError): """ The connection was lost unexpectedly, or a command was run that requires a connection. """
[docs] class SMTPConnectError(SMTPException, ConnectionError): """ An error occurred while connecting to the SMTP server. """
[docs] class SMTPTimeoutError(SMTPException, TimeoutError): """ A timeout occurred while performing a network operation. """
[docs] class SMTPConnectTimeoutError(SMTPTimeoutError, SMTPConnectError): """ A timeout occurred while connecting to the SMTP server. """
[docs] class SMTPReadTimeoutError(SMTPTimeoutError): """ A timeout occurred while waiting for a response from the SMTP server. """
[docs] class SMTPNotSupported(SMTPException): """ A command or argument sent to the SMTP server is not supported. """
[docs] class SMTPResponseException(SMTPException): """ Base class for all server responses with error codes. """ def __init__(self, code: int, message: str, /) -> None: self.code = code self.message = message self.args = (code, message)
[docs] class SMTPConnectResponseError(SMTPResponseException, SMTPConnectError): """ The SMTP server returned an invalid response code after connecting. """
[docs] class SMTPHeloError(SMTPResponseException): """ Server refused HELO or EHLO. """
[docs] class SMTPDataError(SMTPResponseException): """ Server refused DATA content. """
[docs] class SMTPAuthenticationError(SMTPResponseException): """ Server refused our AUTH request; may be caused by invalid credentials. """
[docs] class SMTPSenderRefused(SMTPResponseException): """ SMTP server refused the message sender. """ def __init__(self, code: int, message: str, sender: str, /) -> None: self.code = code self.message = message self.sender = sender self.args = (code, message, sender)
[docs] class SMTPRecipientRefused(SMTPResponseException): """ SMTP server refused a message recipient. """ def __init__(self, code: int, message: str, recipient: str, /) -> None: self.code = code self.message = message self.recipient = recipient self.args = (code, message, recipient)
[docs] class SMTPRecipientsRefused(SMTPException): """ SMTP server refused multiple recipients. """ def __init__(self, recipients: List[SMTPRecipientRefused], /) -> None: self.recipients = recipients self.args = (recipients,)