Debian Codegraph @

jedi/third_party/typeshed/stdlib/smtplib.pyi

raw symbols SCIP
1 import sys
2 from _socket import _Address as _SourceAddress
3 from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath
4 from collections.abc import Sequence
5 from email.message import Message as _Message
6 from re import Pattern
7 from socket import socket
8 from ssl import SSLContext
9 from types import TracebackType
10 from typing import Any, Final, Protocol, overload, type_check_only
11 from typing_extensions import Self, TypeAlias, deprecated
12
13 __all__ = [
14 "SMTPException",
15 "SMTPServerDisconnected",
16 "SMTPResponseException",
17 "SMTPSenderRefused",
18 "SMTPRecipientsRefused",
19 "SMTPDataError",
20 "SMTPConnectError",
21 "SMTPHeloError",
22 "SMTPAuthenticationError",
23 "quoteaddr",
24 "quotedata",
25 "SMTP",
26 "SMTP_SSL",
27 "SMTPNotSupportedError",
28 ]
29
30 _Reply: TypeAlias = tuple[int, bytes]
31 _SendErrs: TypeAlias = dict[str, _Reply]
32
33 SMTP_PORT: Final = 25
34 SMTP_SSL_PORT: Final = 465
35 CRLF: Final[str]
36 bCRLF: Final[bytes]
37
38 OLDSTYLE_AUTH: Final[Pattern[str]]
39
40 class SMTPException(OSError): ...
41 class SMTPNotSupportedError(SMTPException): ...
42 class SMTPServerDisconnected(SMTPException): ...
43
44 class SMTPResponseException(SMTPException):
45 smtp_code: int
46 smtp_error: bytes | str
47 args: tuple[int, bytes | str] | tuple[int, bytes, str]
48 def __init__(self, code: int, msg: bytes | str) -> None: ...
49
50 class SMTPSenderRefused(SMTPResponseException):
51 smtp_error: bytes
52 sender: str
53 args: tuple[int, bytes, str]
54 def __init__(self, code: int, msg: bytes, sender: str) -> None: ...
55
56 class SMTPRecipientsRefused(SMTPException):
57 recipients: _SendErrs
58 args: tuple[_SendErrs]
59 def __init__(self, recipients: _SendErrs) -> None: ...
60
61 class SMTPDataError(SMTPResponseException): ...
62 class SMTPConnectError(SMTPResponseException): ...
63 class SMTPHeloError(SMTPResponseException): ...
64 class SMTPAuthenticationError(SMTPResponseException): ...
65
66 def quoteaddr(addrstring: str) -> str: ...
67 def quotedata(data: str) -> str: ...
68 @type_check_only
69 class _AuthObject(Protocol):
70 @overload
71 def __call__(self, challenge: None = None, /) -> str | None: ...
72 @overload
73 def __call__(self, challenge: bytes, /) -> str: ...
74
75 class SMTP:
76 debuglevel: int
77 sock: socket | None
78 # Type of file should match what socket.makefile() returns
79 file: Any | None
80 helo_resp: bytes | None
81 ehlo_msg: str
82 ehlo_resp: bytes | None
83 does_esmtp: bool
84 default_port: int
85 timeout: float
86 esmtp_features: dict[str, str]
87 command_encoding: str
88 source_address: _SourceAddress | None
89 local_hostname: str
90 def __init__(
91 self,
92 host: str = "",
93 port: int = 0,
94 local_hostname: str | None = None,
95 timeout: float = ...,
96 source_address: _SourceAddress | None = None,
97 ) -> None: ...
98 def __enter__(self) -> Self: ...
99 def __exit__(
100 self, exc_type: type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None
101 ) -> None: ...
102 def set_debuglevel(self, debuglevel: int) -> None: ...
103 def connect(self, host: str = "localhost", port: int = 0, source_address: _SourceAddress | None = None) -> _Reply: ...
104 def send(self, s: ReadableBuffer | str) -> None: ...
105 def putcmd(self, cmd: str, args: str = "") -> None: ...
106 def getreply(self) -> _Reply: ...
107 def docmd(self, cmd: str, args: str = "") -> _Reply: ...
108 def helo(self, name: str = "") -> _Reply: ...
109 def ehlo(self, name: str = "") -> _Reply: ...
110 def has_extn(self, opt: str) -> bool: ...
111 def help(self, args: str = "") -> bytes: ...
112 def rset(self) -> _Reply: ...
113 def noop(self) -> _Reply: ...
114 def mail(self, sender: str, options: Sequence[str] = ()) -> _Reply: ...
115 def rcpt(self, recip: str, options: Sequence[str] = ()) -> _Reply: ...
116 def data(self, msg: ReadableBuffer | str) -> _Reply: ...
117 def verify(self, address: str) -> _Reply: ...
118 vrfy = verify
119 def expn(self, address: str) -> _Reply: ...
120 def ehlo_or_helo_if_needed(self) -> None: ...
121 user: str
122 password: str
123 def auth(self, mechanism: str, authobject: _AuthObject, *, initial_response_ok: bool = True) -> _Reply: ...
124 @overload
125 def auth_cram_md5(self, challenge: None = None) -> None: ...
126 @overload
127 def auth_cram_md5(self, challenge: ReadableBuffer) -> str: ...
128 def auth_plain(self, challenge: ReadableBuffer | None = None) -> str: ...
129 def auth_login(self, challenge: ReadableBuffer | None = None) -> str: ...
130 def login(self, user: str, password: str, *, initial_response_ok: bool = True) -> _Reply: ...
131 if sys.version_info >= (3, 12):
132 def starttls(self, *, context: SSLContext | None = None) -> _Reply: ...
133 else:
134 @overload
135 def starttls(self, keyfile: None = None, certfile: None = None, context: SSLContext | None = None) -> _Reply: ...
136 @overload
137 @deprecated(
138 "The `keyfile`, `certfile` parameters are deprecated since Python 3.6; "
139 "removed in Python 3.12. Use `context` parameter instead."
140 )
141 def starttls(
142 self, keyfile: StrOrBytesPath | None = None, certfile: StrOrBytesPath | None = None, context: None = None
143 ) -> _Reply: ...
144
145 def sendmail(
146 self,
147 from_addr: str,
148 to_addrs: str | Sequence[str],
149 msg: SizedBuffer | str,
150 mail_options: Sequence[str] = (),
151 rcpt_options: Sequence[str] = (),
152 ) -> _SendErrs: ...
153 def send_message(
154 self,
155 msg: _Message,
156 from_addr: str | None = None,
157 to_addrs: str | Sequence[str] | None = None,
158 mail_options: Sequence[str] = (),
159 rcpt_options: Sequence[str] = (),
160 ) -> _SendErrs: ...
161 def close(self) -> None: ...
162 def quit(self) -> _Reply: ...
163
164 class SMTP_SSL(SMTP):
165 context: SSLContext
166 if sys.version_info >= (3, 12):
167 def __init__(
168 self,
169 host: str = "",
170 port: int = 0,
171 local_hostname: str | None = None,
172 *,
173 timeout: float = ...,
174 source_address: _SourceAddress | None = None,
175 context: SSLContext | None = None,
176 ) -> None: ...
177 else:
178 @overload
179 def __init__(
180 self,
181 host: str = "",
182 port: int = 0,
183 local_hostname: str | None = None,
184 keyfile: None = None,
185 certfile: None = None,
186 timeout: float = ...,
187 source_address: _SourceAddress | None = None,
188 context: SSLContext | None = None,
189 ) -> None: ...
190 @overload
191 @deprecated(
192 "The `keyfile`, `certfile` parameters are deprecated since Python 3.6; "
193 "removed in Python 3.12. Use `context` parameter instead."
194 )
195 def __init__(
196 self,
197 host: str = "",
198 port: int = 0,
199 local_hostname: str | None = None,
200 keyfile: StrOrBytesPath | None = None,
201 certfile: StrOrBytesPath | None = None,
202 timeout: float = ...,
203 source_address: _SourceAddress | None = None,
204 context: None = None,
205 ) -> None: ...
206 keyfile: StrOrBytesPath | None
207 certfile: StrOrBytesPath | None
208
209 LMTP_PORT: Final = 2003
210
211 class LMTP(SMTP):
212 def __init__(
213 self,
214 host: str = "",
215 port: int = 2003,
216 local_hostname: str | None = None,
217 source_address: _SourceAddress | None = None,
218 timeout: float = ...,
219 ) -> None: ...