Advertisement
Alexqq11

man smtplib

Sep 15th, 2016
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.93 KB | None | 0 0
  1. Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
  2. Type "copyright", "credits" or "license()" for more information.
  3. >>>
  4. RESTART: C:\Users\Alexqq11\AppData\Local\Programs\Python\Python35-32\mail2.py
  5. New emails with your email in TO is 3
  6. b'Subject: TEST POST IN POST OFFICE'
  7. b'Subject: about russion'
  8. b'Subject: =?utf-8?B?0Y8g0YLQtdCx0LUg0YDRg9GB0YHQutC+0LPQviDQv9GA0LjQvdC10YEg0L/QvtC60YPRiNCw0YLRjCA=?=\r\n\t=?utf-8?B?0LHRgNCw0YLQuNGI0LrQsA==?='
  9. >>> help(imaplib.fetch())
  10. Traceback (most recent call last):
  11. File "<pyshell#0>", line 1, in <module>
  12. help(imaplib.fetch())
  13. AttributeError: module 'imaplib' has no attribute 'fetch'
  14. >>> import smtp
  15. Traceback (most recent call last):
  16. File "<pyshell#1>", line 1, in <module>
  17. import smtp
  18. ImportError: No module named 'smtp'
  19. >>> import smtplib
  20. >>> help(smtplib)
  21. Help on module smtplib:
  22.  
  23. NAME
  24. smtplib - SMTP/ESMTP client class.
  25.  
  26. DESCRIPTION
  27. This should follow RFC 821 (SMTP), RFC 1869 (ESMTP), RFC 2554 (SMTP
  28. Authentication) and RFC 2487 (Secure SMTP over TLS).
  29.  
  30. Notes:
  31.  
  32. Please remember, when doing ESMTP, that the names of the SMTP service
  33. extensions are NOT the same thing as the option keywords for the RCPT
  34. and MAIL commands!
  35.  
  36. Example:
  37.  
  38. >>> import smtplib
  39. >>> s=smtplib.SMTP("localhost")
  40. >>> print(s.help())
  41. This is Sendmail version 8.8.4
  42. Topics:
  43. HELO EHLO MAIL RCPT DATA
  44. RSET NOOP QUIT HELP VRFY
  45. EXPN VERB ETRN DSN
  46. For more info use "HELP <topic>".
  47. To report bugs in the implementation send email to
  48. sendmail-bugs@sendmail.org.
  49. For local information send email to Postmaster at your site.
  50. End of HELP info
  51. >>> s.putcmd("vrfy","someone@here")
  52. >>> s.getreply()
  53. (250, "Somebody OverHere <somebody@here.my.org>")
  54. >>> s.quit()
  55.  
  56. CLASSES
  57. builtins.OSError(builtins.Exception)
  58. SMTPException
  59. SMTPRecipientsRefused
  60. SMTPResponseException
  61. SMTPAuthenticationError
  62. SMTPConnectError
  63. SMTPDataError
  64. SMTPHeloError
  65. SMTPSenderRefused
  66. SMTPServerDisconnected
  67. builtins.object
  68. SMTP
  69. SMTP_SSL
  70.  
  71. class SMTP(builtins.object)
  72. | This class manages a connection to an SMTP or ESMTP server.
  73. | SMTP Objects:
  74. | SMTP objects have the following attributes:
  75. | helo_resp
  76. | This is the message given by the server in response to the
  77. | most recent HELO command.
  78. |
  79. | ehlo_resp
  80. | This is the message given by the server in response to the
  81. | most recent EHLO command. This is usually multiline.
  82. |
  83. | does_esmtp
  84. | This is a True value _after you do an EHLO command_, if the
  85. | server supports ESMTP.
  86. |
  87. | esmtp_features
  88. | This is a dictionary, which, if the server supports ESMTP,
  89. | will _after you do an EHLO command_, contain the names of the
  90. | SMTP service extensions this server supports, and their
  91. | parameters (if any).
  92. |
  93. | Note, all extension names are mapped to lower case in the
  94. | dictionary.
  95. |
  96. | See each method's docstrings for details. In general, there is a
  97. | method of the same name to perform each SMTP command. There is also a
  98. | method called 'sendmail' that will do an entire mail transaction.
  99. |
  100. | Methods defined here:
  101. |
  102. | __enter__(self)
  103. |
  104. | __exit__(self, *args)
  105. |
  106. | __init__(self, host='', port=0, local_hostname=None, timeout=<object object at 0x00CD8D70>, source_address=None)
  107. | Initialize a new instance.
  108. |
  109. | If specified, `host' is the name of the remote host to which to
  110. | connect. If specified, `port' specifies the port to which to connect.
  111. | By default, smtplib.SMTP_PORT is used. If a host is specified the
  112. | connect method is called, and if it returns anything other than a
  113. | success code an SMTPConnectError is raised. If specified,
  114. | `local_hostname` is used as the FQDN of the local host in the HELO/EHLO
  115. | command. Otherwise, the local hostname is found using
  116. | socket.getfqdn(). The `source_address` parameter takes a 2-tuple (host,
  117. | port) for the socket to bind to as its source address before
  118. | connecting. If the host is '' and port is 0, the OS default behavior
  119. | will be used.
  120. |
  121. | auth(self, mechanism, authobject, *, initial_response_ok=True)
  122. | Authentication command - requires response processing.
  123. |
  124. | 'mechanism' specifies which authentication mechanism is to
  125. | be used - the valid values are those listed in the 'auth'
  126. | element of 'esmtp_features'.
  127. |
  128. | 'authobject' must be a callable object taking a single argument:
  129. |
  130. | data = authobject(challenge)
  131. |
  132. | It will be called to process the server's challenge response; the
  133. | challenge argument it is passed will be a bytes. It should return
  134. | bytes data that will be base64 encoded and sent to the server.
  135. |
  136. | Keyword arguments:
  137. | - initial_response_ok: Allow sending the RFC 4954 initial-response
  138. | to the AUTH command, if the authentication methods supports it.
  139. |
  140. | auth_cram_md5(self, challenge=None)
  141. | Authobject to use with CRAM-MD5 authentication. Requires self.user
  142. | and self.password to be set.
  143. |
  144. | auth_login(self, challenge=None)
  145. | Authobject to use with LOGIN authentication. Requires self.user and
  146. | self.password to be set.
  147. |
  148. | auth_plain(self, challenge=None)
  149. | Authobject to use with PLAIN authentication. Requires self.user and
  150. | self.password to be set.
  151. |
  152. | close(self)
  153. | Close the connection to the SMTP server.
  154. |
  155. | connect(self, host='localhost', port=0, source_address=None)
  156. | Connect to a host on a given port.
  157. |
  158. | If the hostname ends with a colon (`:') followed by a number, and
  159. | there is no port specified, that suffix will be stripped off and the
  160. | number interpreted as the port number to use.
  161. |
  162. | Note: This method is automatically invoked by __init__, if a host is
  163. | specified during instantiation.
  164. |
  165. | data(self, msg)
  166. | SMTP 'DATA' command -- sends message data to server.
  167. |
  168. | Automatically quotes lines beginning with a period per rfc821.
  169. | Raises SMTPDataError if there is an unexpected reply to the
  170. | DATA command; the return value from this method is the final
  171. | response code received when the all data is sent. If msg
  172. | is a string, lone '\r' and '\n' characters are converted to
  173. | '\r\n' characters. If msg is bytes, it is transmitted as is.
  174. |
  175. | docmd(self, cmd, args='')
  176. | Send a command, and return its response code.
  177. |
  178. | ehlo(self, name='')
  179. | SMTP 'ehlo' command.
  180. | Hostname to send for this command defaults to the FQDN of the local
  181. | host.
  182. |
  183. | ehlo_or_helo_if_needed(self)
  184. | Call self.ehlo() and/or self.helo() if needed.
  185. |
  186. | If there has been no previous EHLO or HELO command this session, this
  187. | method tries ESMTP EHLO first.
  188. |
  189. | This method may raise the following exceptions:
  190. |
  191. | SMTPHeloError The server didn't reply properly to
  192. | the helo greeting.
  193. |
  194. | expn(self, address)
  195. | SMTP 'expn' command -- expands a mailing list.
  196. |
  197. | getreply(self)
  198. | Get a reply from the server.
  199. |
  200. | Returns a tuple consisting of:
  201. |
  202. | - server response code (e.g. '250', or such, if all goes well)
  203. | Note: returns -1 if it can't read response code.
  204. |
  205. | - server response string corresponding to response code (multiline
  206. | responses are converted to a single, multiline string).
  207. |
  208. | Raises SMTPServerDisconnected if end-of-file is reached.
  209. |
  210. | has_extn(self, opt)
  211. | Does the server support a given SMTP service extension?
  212. |
  213. | helo(self, name='')
  214. | SMTP 'helo' command.
  215. | Hostname to send for this command defaults to the FQDN of the local
  216. | host.
  217. |
  218. | help(self, args='')
  219. | SMTP 'help' command.
  220. | Returns help text from server.
  221. |
  222. | login(self, user, password, *, initial_response_ok=True)
  223. | Log in on an SMTP server that requires authentication.
  224. |
  225. | The arguments are:
  226. | - user: The user name to authenticate with.
  227. | - password: The password for the authentication.
  228. |
  229. | Keyword arguments:
  230. | - initial_response_ok: Allow sending the RFC 4954 initial-response
  231. | to the AUTH command, if the authentication methods supports it.
  232. |
  233. | If there has been no previous EHLO or HELO command this session, this
  234. | method tries ESMTP EHLO first.
  235. |
  236. | This method will return normally if the authentication was successful.
  237. |
  238. | This method may raise the following exceptions:
  239. |
  240. | SMTPHeloError The server didn't reply properly to
  241. | the helo greeting.
  242. | SMTPAuthenticationError The server didn't accept the username/
  243. | password combination.
  244. | SMTPNotSupportedError The AUTH command is not supported by the
  245. | server.
  246. | SMTPException No suitable authentication method was
  247. | found.
  248. |
  249. | mail(self, sender, options=[])
  250. | SMTP 'mail' command -- begins mail xfer session.
  251. |
  252. | This method may raise the following exceptions:
  253. |
  254. | SMTPNotSupportedError The options parameter includes 'SMTPUTF8'
  255. | but the SMTPUTF8 extension is not supported by
  256. | the server.
  257. |
  258. | noop(self)
  259. | SMTP 'noop' command -- doesn't do anything :>
  260. |
  261. | putcmd(self, cmd, args='')
  262. | Send a command to the server.
  263. |
  264. | quit(self)
  265. | Terminate the SMTP session.
  266. |
  267. | rcpt(self, recip, options=[])
  268. | SMTP 'rcpt' command -- indicates 1 recipient for this mail.
  269. |
  270. | rset(self)
  271. | SMTP 'rset' command -- resets session.
  272. |
  273. | send(self, s)
  274. | Send `s' to the server.
  275. |
  276. | send_message(self, msg, from_addr=None, to_addrs=None, mail_options=[], rcpt_options={})
  277. | Converts message to a bytestring and passes it to sendmail.
  278. |
  279. | The arguments are as for sendmail, except that msg is an
  280. | email.message.Message object. If from_addr is None or to_addrs is
  281. | None, these arguments are taken from the headers of the Message as
  282. | described in RFC 2822 (a ValueError is raised if there is more than
  283. | one set of 'Resent-' headers). Regardless of the values of from_addr and
  284. | to_addr, any Bcc field (or Resent-Bcc field, when the Message is a
  285. | resent) of the Message object won't be transmitted. The Message
  286. | object is then serialized using email.generator.BytesGenerator and
  287. | sendmail is called to transmit the message. If the sender or any of
  288. | the recipient addresses contain non-ASCII and the server advertises the
  289. | SMTPUTF8 capability, the policy is cloned with utf8 set to True for the
  290. | serialization, and SMTPUTF8 and BODY=8BITMIME are asserted on the send.
  291. | If the server does not support SMTPUTF8, an SMPTNotSupported error is
  292. | raised. Otherwise the generator is called without modifying the
  293. | policy.
  294. |
  295. | sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[])
  296. | This command performs an entire mail transaction.
  297. |
  298. | The arguments are:
  299. | - from_addr : The address sending this mail.
  300. | - to_addrs : A list of addresses to send this mail to. A bare
  301. | string will be treated as a list with 1 address.
  302. | - msg : The message to send.
  303. | - mail_options : List of ESMTP options (such as 8bitmime) for the
  304. | mail command.
  305. | - rcpt_options : List of ESMTP options (such as DSN commands) for
  306. | all the rcpt commands.
  307. |
  308. | msg may be a string containing characters in the ASCII range, or a byte
  309. | string. A string is encoded to bytes using the ascii codec, and lone
  310. | \r and \n characters are converted to \r\n characters.
  311. |
  312. | If there has been no previous EHLO or HELO command this session, this
  313. | method tries ESMTP EHLO first. If the server does ESMTP, message size
  314. | and each of the specified options will be passed to it. If EHLO
  315. | fails, HELO will be tried and ESMTP options suppressed.
  316. |
  317. | This method will return normally if the mail is accepted for at least
  318. | one recipient. It returns a dictionary, with one entry for each
  319. | recipient that was refused. Each entry contains a tuple of the SMTP
  320. | error code and the accompanying error message sent by the server.
  321. |
  322. | This method may raise the following exceptions:
  323. |
  324. | SMTPHeloError The server didn't reply properly to
  325. | the helo greeting.
  326. | SMTPRecipientsRefused The server rejected ALL recipients
  327. | (no mail was sent).
  328. | SMTPSenderRefused The server didn't accept the from_addr.
  329. | SMTPDataError The server replied with an unexpected
  330. | error code (other than a refusal of
  331. | a recipient).
  332. | SMTPNotSupportedError The mail_options parameter includes 'SMTPUTF8'
  333. | but the SMTPUTF8 extension is not supported by
  334. | the server.
  335. |
  336. | Note: the connection will be open even after an exception is raised.
  337. |
  338. | Example:
  339. |
  340. | >>> import smtplib
  341. | >>> s=smtplib.SMTP("localhost")
  342. | >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"]
  343. | >>> msg = '''\
  344. | ... From: Me@my.org
  345. | ... Subject: testin'...
  346. | ...
  347. | ... This is a test '''
  348. | >>> s.sendmail("me@my.org",tolist,msg)
  349. | { "three@three.org" : ( 550 ,"User unknown" ) }
  350. | >>> s.quit()
  351. |
  352. | In the above example, the message was accepted for delivery to three
  353. | of the four addresses, and one was rejected, with the error code
  354. | 550. If all addresses are accepted, then the method will return an
  355. | empty dictionary.
  356. |
  357. | set_debuglevel(self, debuglevel)
  358. | Set the debug output level.
  359. |
  360. | A non-false value results in debug messages for connection and for all
  361. | messages sent to and received from the server.
  362. |
  363. | starttls(self, keyfile=None, certfile=None, context=None)
  364. | Puts the connection to the SMTP server into TLS mode.
  365. |
  366. | If there has been no previous EHLO or HELO command this session, this
  367. | method tries ESMTP EHLO first.
  368. |
  369. | If the server supports TLS, this will encrypt the rest of the SMTP
  370. | session. If you provide the keyfile and certfile parameters,
  371. | the identity of the SMTP server and client can be checked. This,
  372. | however, depends on whether the socket module really checks the
  373. | certificates.
  374. |
  375. | This method may raise the following exceptions:
  376. |
  377. | SMTPHeloError The server didn't reply properly to
  378. | the helo greeting.
  379. |
  380. | verify(self, address)
  381. | SMTP 'verify' command -- checks for address validity.
  382. |
  383. | vrfy = verify(self, address)
  384. |
  385. | ----------------------------------------------------------------------
  386. | Data descriptors defined here:
  387. |
  388. | __dict__
  389. | dictionary for instance variables (if defined)
  390. |
  391. | __weakref__
  392. | list of weak references to the object (if defined)
  393. |
  394. | ----------------------------------------------------------------------
  395. | Data and other attributes defined here:
  396. |
  397. | debuglevel = 0
  398. |
  399. | default_port = 25
  400. |
  401. | does_esmtp = 0
  402. |
  403. | ehlo_msg = 'ehlo'
  404. |
  405. | ehlo_resp = None
  406. |
  407. | file = None
  408. |
  409. | helo_resp = None
  410.  
  411. class SMTPAuthenticationError(SMTPResponseException)
  412. | Authentication error.
  413. |
  414. | Most probably the server didn't accept the username/password
  415. | combination provided.
  416. |
  417. | Method resolution order:
  418. | SMTPAuthenticationError
  419. | SMTPResponseException
  420. | SMTPException
  421. | builtins.OSError
  422. | builtins.Exception
  423. | builtins.BaseException
  424. | builtins.object
  425. |
  426. | Methods inherited from SMTPResponseException:
  427. |
  428. | __init__(self, code, msg)
  429. | Initialize self. See help(type(self)) for accurate signature.
  430. |
  431. | ----------------------------------------------------------------------
  432. | Data descriptors inherited from SMTPException:
  433. |
  434. | __weakref__
  435. | list of weak references to the object (if defined)
  436. |
  437. | ----------------------------------------------------------------------
  438. | Methods inherited from builtins.OSError:
  439. |
  440. | __new__(*args, **kwargs) from builtins.type
  441. | Create and return a new object. See help(type) for accurate signature.
  442. |
  443. | __reduce__(...)
  444. | helper for pickle
  445. |
  446. | __str__(self, /)
  447. | Return str(self).
  448. |
  449. | ----------------------------------------------------------------------
  450. | Data descriptors inherited from builtins.OSError:
  451. |
  452. | characters_written
  453. |
  454. | errno
  455. | POSIX exception code
  456. |
  457. | filename
  458. | exception filename
  459. |
  460. | filename2
  461. | second exception filename
  462. |
  463. | strerror
  464. | exception strerror
  465. |
  466. | winerror
  467. | Win32 exception code
  468. |
  469. | ----------------------------------------------------------------------
  470. | Methods inherited from builtins.BaseException:
  471. |
  472. | __delattr__(self, name, /)
  473. | Implement delattr(self, name).
  474. |
  475. | __getattribute__(self, name, /)
  476. | Return getattr(self, name).
  477. |
  478. | __repr__(self, /)
  479. | Return repr(self).
  480. |
  481. | __setattr__(self, name, value, /)
  482. | Implement setattr(self, name, value).
  483. |
  484. | __setstate__(...)
  485. |
  486. | with_traceback(...)
  487. | Exception.with_traceback(tb) --
  488. | set self.__traceback__ to tb and return self.
  489. |
  490. | ----------------------------------------------------------------------
  491. | Data descriptors inherited from builtins.BaseException:
  492. |
  493. | __cause__
  494. | exception cause
  495. |
  496. | __context__
  497. | exception context
  498. |
  499. | __dict__
  500. |
  501. | __suppress_context__
  502. |
  503. | __traceback__
  504. |
  505. | args
  506.  
  507. class SMTPConnectError(SMTPResponseException)
  508. | Error during connection establishment.
  509. |
  510. | Method resolution order:
  511. | SMTPConnectError
  512. | SMTPResponseException
  513. | SMTPException
  514. | builtins.OSError
  515. | builtins.Exception
  516. | builtins.BaseException
  517. | builtins.object
  518. |
  519. | Methods inherited from SMTPResponseException:
  520. |
  521. | __init__(self, code, msg)
  522. | Initialize self. See help(type(self)) for accurate signature.
  523. |
  524. | ----------------------------------------------------------------------
  525. | Data descriptors inherited from SMTPException:
  526. |
  527. | __weakref__
  528. | list of weak references to the object (if defined)
  529. |
  530. | ----------------------------------------------------------------------
  531. | Methods inherited from builtins.OSError:
  532. |
  533. | __new__(*args, **kwargs) from builtins.type
  534. | Create and return a new object. See help(type) for accurate signature.
  535. |
  536. | __reduce__(...)
  537. | helper for pickle
  538. |
  539. | __str__(self, /)
  540. | Return str(self).
  541. |
  542. | ----------------------------------------------------------------------
  543. | Data descriptors inherited from builtins.OSError:
  544. |
  545. | characters_written
  546. |
  547. | errno
  548. | POSIX exception code
  549. |
  550. | filename
  551. | exception filename
  552. |
  553. | filename2
  554. | second exception filename
  555. |
  556. | strerror
  557. | exception strerror
  558. |
  559. | winerror
  560. | Win32 exception code
  561. |
  562. | ----------------------------------------------------------------------
  563. | Methods inherited from builtins.BaseException:
  564. |
  565. | __delattr__(self, name, /)
  566. | Implement delattr(self, name).
  567. |
  568. | __getattribute__(self, name, /)
  569. | Return getattr(self, name).
  570. |
  571. | __repr__(self, /)
  572. | Return repr(self).
  573. |
  574. | __setattr__(self, name, value, /)
  575. | Implement setattr(self, name, value).
  576. |
  577. | __setstate__(...)
  578. |
  579. | with_traceback(...)
  580. | Exception.with_traceback(tb) --
  581. | set self.__traceback__ to tb and return self.
  582. |
  583. | ----------------------------------------------------------------------
  584. | Data descriptors inherited from builtins.BaseException:
  585. |
  586. | __cause__
  587. | exception cause
  588. |
  589. | __context__
  590. | exception context
  591. |
  592. | __dict__
  593. |
  594. | __suppress_context__
  595. |
  596. | __traceback__
  597. |
  598. | args
  599.  
  600. class SMTPDataError(SMTPResponseException)
  601. | The SMTP server didn't accept the data.
  602. |
  603. | Method resolution order:
  604. | SMTPDataError
  605. | SMTPResponseException
  606. | SMTPException
  607. | builtins.OSError
  608. | builtins.Exception
  609. | builtins.BaseException
  610. | builtins.object
  611. |
  612. | Methods inherited from SMTPResponseException:
  613. |
  614. | __init__(self, code, msg)
  615. | Initialize self. See help(type(self)) for accurate signature.
  616. |
  617. | ----------------------------------------------------------------------
  618. | Data descriptors inherited from SMTPException:
  619. |
  620. | __weakref__
  621. | list of weak references to the object (if defined)
  622. |
  623. | ----------------------------------------------------------------------
  624. | Methods inherited from builtins.OSError:
  625. |
  626. | __new__(*args, **kwargs) from builtins.type
  627. | Create and return a new object. See help(type) for accurate signature.
  628. |
  629. | __reduce__(...)
  630. | helper for pickle
  631. |
  632. | __str__(self, /)
  633. | Return str(self).
  634. |
  635. | ----------------------------------------------------------------------
  636. | Data descriptors inherited from builtins.OSError:
  637. |
  638. | characters_written
  639. |
  640. | errno
  641. | POSIX exception code
  642. |
  643. | filename
  644. | exception filename
  645. |
  646. | filename2
  647. | second exception filename
  648. |
  649. | strerror
  650. | exception strerror
  651. |
  652. | winerror
  653. | Win32 exception code
  654. |
  655. | ----------------------------------------------------------------------
  656. | Methods inherited from builtins.BaseException:
  657. |
  658. | __delattr__(self, name, /)
  659. | Implement delattr(self, name).
  660. |
  661. | __getattribute__(self, name, /)
  662. | Return getattr(self, name).
  663. |
  664. | __repr__(self, /)
  665. | Return repr(self).
  666. |
  667. | __setattr__(self, name, value, /)
  668. | Implement setattr(self, name, value).
  669. |
  670. | __setstate__(...)
  671. |
  672. | with_traceback(...)
  673. | Exception.with_traceback(tb) --
  674. | set self.__traceback__ to tb and return self.
  675. |
  676. | ----------------------------------------------------------------------
  677. | Data descriptors inherited from builtins.BaseException:
  678. |
  679. | __cause__
  680. | exception cause
  681. |
  682. | __context__
  683. | exception context
  684. |
  685. | __dict__
  686. |
  687. | __suppress_context__
  688. |
  689. | __traceback__
  690. |
  691. | args
  692.  
  693. class SMTPException(builtins.OSError)
  694. | Base class for all exceptions raised by this module.
  695. |
  696. | Method resolution order:
  697. | SMTPException
  698. | builtins.OSError
  699. | builtins.Exception
  700. | builtins.BaseException
  701. | builtins.object
  702. |
  703. | Data descriptors defined here:
  704. |
  705. | __weakref__
  706. | list of weak references to the object (if defined)
  707. |
  708. | ----------------------------------------------------------------------
  709. | Methods inherited from builtins.OSError:
  710. |
  711. | __init__(self, /, *args, **kwargs)
  712. | Initialize self. See help(type(self)) for accurate signature.
  713. |
  714. | __new__(*args, **kwargs) from builtins.type
  715. | Create and return a new object. See help(type) for accurate signature.
  716. |
  717. | __reduce__(...)
  718. | helper for pickle
  719. |
  720. | __str__(self, /)
  721. | Return str(self).
  722. |
  723. | ----------------------------------------------------------------------
  724. | Data descriptors inherited from builtins.OSError:
  725. |
  726. | characters_written
  727. |
  728. | errno
  729. | POSIX exception code
  730. |
  731. | filename
  732. | exception filename
  733. |
  734. | filename2
  735. | second exception filename
  736. |
  737. | strerror
  738. | exception strerror
  739. |
  740. | winerror
  741. | Win32 exception code
  742. |
  743. | ----------------------------------------------------------------------
  744. | Methods inherited from builtins.BaseException:
  745. |
  746. | __delattr__(self, name, /)
  747. | Implement delattr(self, name).
  748. |
  749. | __getattribute__(self, name, /)
  750. | Return getattr(self, name).
  751. |
  752. | __repr__(self, /)
  753. | Return repr(self).
  754. |
  755. | __setattr__(self, name, value, /)
  756. | Implement setattr(self, name, value).
  757. |
  758. | __setstate__(...)
  759. |
  760. | with_traceback(...)
  761. | Exception.with_traceback(tb) --
  762. | set self.__traceback__ to tb and return self.
  763. |
  764. | ----------------------------------------------------------------------
  765. | Data descriptors inherited from builtins.BaseException:
  766. |
  767. | __cause__
  768. | exception cause
  769. |
  770. | __context__
  771. | exception context
  772. |
  773. | __dict__
  774. |
  775. | __suppress_context__
  776. |
  777. | __traceback__
  778. |
  779. | args
  780.  
  781. class SMTPHeloError(SMTPResponseException)
  782. | The server refused our HELO reply.
  783. |
  784. | Method resolution order:
  785. | SMTPHeloError
  786. | SMTPResponseException
  787. | SMTPException
  788. | builtins.OSError
  789. | builtins.Exception
  790. | builtins.BaseException
  791. | builtins.object
  792. |
  793. | Methods inherited from SMTPResponseException:
  794. |
  795. | __init__(self, code, msg)
  796. | Initialize self. See help(type(self)) for accurate signature.
  797. |
  798. | ----------------------------------------------------------------------
  799. | Data descriptors inherited from SMTPException:
  800. |
  801. | __weakref__
  802. | list of weak references to the object (if defined)
  803. |
  804. | ----------------------------------------------------------------------
  805. | Methods inherited from builtins.OSError:
  806. |
  807. | __new__(*args, **kwargs) from builtins.type
  808. | Create and return a new object. See help(type) for accurate signature.
  809. |
  810. | __reduce__(...)
  811. | helper for pickle
  812. |
  813. | __str__(self, /)
  814. | Return str(self).
  815. |
  816. | ----------------------------------------------------------------------
  817. | Data descriptors inherited from builtins.OSError:
  818. |
  819. | characters_written
  820. |
  821. | errno
  822. | POSIX exception code
  823. |
  824. | filename
  825. | exception filename
  826. |
  827. | filename2
  828. | second exception filename
  829. |
  830. | strerror
  831. | exception strerror
  832. |
  833. | winerror
  834. | Win32 exception code
  835. |
  836. | ----------------------------------------------------------------------
  837. | Methods inherited from builtins.BaseException:
  838. |
  839. | __delattr__(self, name, /)
  840. | Implement delattr(self, name).
  841. |
  842. | __getattribute__(self, name, /)
  843. | Return getattr(self, name).
  844. |
  845. | __repr__(self, /)
  846. | Return repr(self).
  847. |
  848. | __setattr__(self, name, value, /)
  849. | Implement setattr(self, name, value).
  850. |
  851. | __setstate__(...)
  852. |
  853. | with_traceback(...)
  854. | Exception.with_traceback(tb) --
  855. | set self.__traceback__ to tb and return self.
  856. |
  857. | ----------------------------------------------------------------------
  858. | Data descriptors inherited from builtins.BaseException:
  859. |
  860. | __cause__
  861. | exception cause
  862. |
  863. | __context__
  864. | exception context
  865. |
  866. | __dict__
  867. |
  868. | __suppress_context__
  869. |
  870. | __traceback__
  871. |
  872. | args
  873.  
  874. class SMTPRecipientsRefused(SMTPException)
  875. | All recipient addresses refused.
  876. |
  877. | The errors for each recipient are accessible through the attribute
  878. | 'recipients', which is a dictionary of exactly the same sort as
  879. | SMTP.sendmail() returns.
  880. |
  881. | Method resolution order:
  882. | SMTPRecipientsRefused
  883. | SMTPException
  884. | builtins.OSError
  885. | builtins.Exception
  886. | builtins.BaseException
  887. | builtins.object
  888. |
  889. | Methods defined here:
  890. |
  891. | __init__(self, recipients)
  892. | Initialize self. See help(type(self)) for accurate signature.
  893. |
  894. | ----------------------------------------------------------------------
  895. | Data descriptors inherited from SMTPException:
  896. |
  897. | __weakref__
  898. | list of weak references to the object (if defined)
  899. |
  900. | ----------------------------------------------------------------------
  901. | Methods inherited from builtins.OSError:
  902. |
  903. | __new__(*args, **kwargs) from builtins.type
  904. | Create and return a new object. See help(type) for accurate signature.
  905. |
  906. | __reduce__(...)
  907. | helper for pickle
  908. |
  909. | __str__(self, /)
  910. | Return str(self).
  911. |
  912. | ----------------------------------------------------------------------
  913. | Data descriptors inherited from builtins.OSError:
  914. |
  915. | characters_written
  916. |
  917. | errno
  918. | POSIX exception code
  919. |
  920. | filename
  921. | exception filename
  922. |
  923. | filename2
  924. | second exception filename
  925. |
  926. | strerror
  927. | exception strerror
  928. |
  929. | winerror
  930. | Win32 exception code
  931. |
  932. | ----------------------------------------------------------------------
  933. | Methods inherited from builtins.BaseException:
  934. |
  935. | __delattr__(self, name, /)
  936. | Implement delattr(self, name).
  937. |
  938. | __getattribute__(self, name, /)
  939. | Return getattr(self, name).
  940. |
  941. | __repr__(self, /)
  942. | Return repr(self).
  943. |
  944. | __setattr__(self, name, value, /)
  945. | Implement setattr(self, name, value).
  946. |
  947. | __setstate__(...)
  948. |
  949. | with_traceback(...)
  950. | Exception.with_traceback(tb) --
  951. | set self.__traceback__ to tb and return self.
  952. |
  953. | ----------------------------------------------------------------------
  954. | Data descriptors inherited from builtins.BaseException:
  955. |
  956. | __cause__
  957. | exception cause
  958. |
  959. | __context__
  960. | exception context
  961. |
  962. | __dict__
  963. |
  964. | __suppress_context__
  965. |
  966. | __traceback__
  967. |
  968. | args
  969.  
  970. class SMTPResponseException(SMTPException)
  971. | Base class for all exceptions that include an SMTP error code.
  972. |
  973. | These exceptions are generated in some instances when the SMTP
  974. | server returns an error code. The error code is stored in the
  975. | `smtp_code' attribute of the error, and the `smtp_error' attribute
  976. | is set to the error message.
  977. |
  978. | Method resolution order:
  979. | SMTPResponseException
  980. | SMTPException
  981. | builtins.OSError
  982. | builtins.Exception
  983. | builtins.BaseException
  984. | builtins.object
  985. |
  986. | Methods defined here:
  987. |
  988. | __init__(self, code, msg)
  989. | Initialize self. See help(type(self)) for accurate signature.
  990. |
  991. | ----------------------------------------------------------------------
  992. | Data descriptors inherited from SMTPException:
  993. |
  994. | __weakref__
  995. | list of weak references to the object (if defined)
  996. |
  997. | ----------------------------------------------------------------------
  998. | Methods inherited from builtins.OSError:
  999. |
  1000. | __new__(*args, **kwargs) from builtins.type
  1001. | Create and return a new object. See help(type) for accurate signature.
  1002. |
  1003. | __reduce__(...)
  1004. | helper for pickle
  1005. |
  1006. | __str__(self, /)
  1007. | Return str(self).
  1008. |
  1009. | ----------------------------------------------------------------------
  1010. | Data descriptors inherited from builtins.OSError:
  1011. |
  1012. | characters_written
  1013. |
  1014. | errno
  1015. | POSIX exception code
  1016. |
  1017. | filename
  1018. | exception filename
  1019. |
  1020. | filename2
  1021. | second exception filename
  1022. |
  1023. | strerror
  1024. | exception strerror
  1025. |
  1026. | winerror
  1027. | Win32 exception code
  1028. |
  1029. | ----------------------------------------------------------------------
  1030. | Methods inherited from builtins.BaseException:
  1031. |
  1032. | __delattr__(self, name, /)
  1033. | Implement delattr(self, name).
  1034. |
  1035. | __getattribute__(self, name, /)
  1036. | Return getattr(self, name).
  1037. |
  1038. | __repr__(self, /)
  1039. | Return repr(self).
  1040. |
  1041. | __setattr__(self, name, value, /)
  1042. | Implement setattr(self, name, value).
  1043. |
  1044. | __setstate__(...)
  1045. |
  1046. | with_traceback(...)
  1047. | Exception.with_traceback(tb) --
  1048. | set self.__traceback__ to tb and return self.
  1049. |
  1050. | ----------------------------------------------------------------------
  1051. | Data descriptors inherited from builtins.BaseException:
  1052. |
  1053. | __cause__
  1054. | exception cause
  1055. |
  1056. | __context__
  1057. | exception context
  1058. |
  1059. | __dict__
  1060. |
  1061. | __suppress_context__
  1062. |
  1063. | __traceback__
  1064. |
  1065. | args
  1066.  
  1067. class SMTPSenderRefused(SMTPResponseException)
  1068. | Sender address refused.
  1069. |
  1070. | In addition to the attributes set by on all SMTPResponseException
  1071. | exceptions, this sets `sender' to the string that the SMTP refused.
  1072. |
  1073. | Method resolution order:
  1074. | SMTPSenderRefused
  1075. | SMTPResponseException
  1076. | SMTPException
  1077. | builtins.OSError
  1078. | builtins.Exception
  1079. | builtins.BaseException
  1080. | builtins.object
  1081. |
  1082. | Methods defined here:
  1083. |
  1084. | __init__(self, code, msg, sender)
  1085. | Initialize self. See help(type(self)) for accurate signature.
  1086. |
  1087. | ----------------------------------------------------------------------
  1088. | Data descriptors inherited from SMTPException:
  1089. |
  1090. | __weakref__
  1091. | list of weak references to the object (if defined)
  1092. |
  1093. | ----------------------------------------------------------------------
  1094. | Methods inherited from builtins.OSError:
  1095. |
  1096. | __new__(*args, **kwargs) from builtins.type
  1097. | Create and return a new object. See help(type) for accurate signature.
  1098. |
  1099. | __reduce__(...)
  1100. | helper for pickle
  1101. |
  1102. | __str__(self, /)
  1103. | Return str(self).
  1104. |
  1105. | ----------------------------------------------------------------------
  1106. | Data descriptors inherited from builtins.OSError:
  1107. |
  1108. | characters_written
  1109. |
  1110. | errno
  1111. | POSIX exception code
  1112. |
  1113. | filename
  1114. | exception filename
  1115. |
  1116. | filename2
  1117. | second exception filename
  1118. |
  1119. | strerror
  1120. | exception strerror
  1121. |
  1122. | winerror
  1123. | Win32 exception code
  1124. |
  1125. | ----------------------------------------------------------------------
  1126. | Methods inherited from builtins.BaseException:
  1127. |
  1128. | __delattr__(self, name, /)
  1129. | Implement delattr(self, name).
  1130. |
  1131. | __getattribute__(self, name, /)
  1132. | Return getattr(self, name).
  1133. |
  1134. | __repr__(self, /)
  1135. | Return repr(self).
  1136. |
  1137. | __setattr__(self, name, value, /)
  1138. | Implement setattr(self, name, value).
  1139. |
  1140. | __setstate__(...)
  1141. |
  1142. | with_traceback(...)
  1143. | Exception.with_traceback(tb) --
  1144. | set self.__traceback__ to tb and return self.
  1145. |
  1146. | ----------------------------------------------------------------------
  1147. | Data descriptors inherited from builtins.BaseException:
  1148. |
  1149. | __cause__
  1150. | exception cause
  1151. |
  1152. | __context__
  1153. | exception context
  1154. |
  1155. | __dict__
  1156. |
  1157. | __suppress_context__
  1158. |
  1159. | __traceback__
  1160. |
  1161. | args
  1162.  
  1163. class SMTPServerDisconnected(SMTPException)
  1164. | Not connected to any SMTP server.
  1165. |
  1166. | This exception is raised when the server unexpectedly disconnects,
  1167. | or when an attempt is made to use the SMTP instance before
  1168. | connecting it to a server.
  1169. |
  1170. | Method resolution order:
  1171. | SMTPServerDisconnected
  1172. | SMTPException
  1173. | builtins.OSError
  1174. | builtins.Exception
  1175. | builtins.BaseException
  1176. | builtins.object
  1177. |
  1178. | Data descriptors inherited from SMTPException:
  1179. |
  1180. | __weakref__
  1181. | list of weak references to the object (if defined)
  1182. |
  1183. | ----------------------------------------------------------------------
  1184. | Methods inherited from builtins.OSError:
  1185. |
  1186. | __init__(self, /, *args, **kwargs)
  1187. | Initialize self. See help(type(self)) for accurate signature.
  1188. |
  1189. | __new__(*args, **kwargs) from builtins.type
  1190. | Create and return a new object. See help(type) for accurate signature.
  1191. |
  1192. | __reduce__(...)
  1193. | helper for pickle
  1194. |
  1195. | __str__(self, /)
  1196. | Return str(self).
  1197. |
  1198. | ----------------------------------------------------------------------
  1199. | Data descriptors inherited from builtins.OSError:
  1200. |
  1201. | characters_written
  1202. |
  1203. | errno
  1204. | POSIX exception code
  1205. |
  1206. | filename
  1207. | exception filename
  1208. |
  1209. | filename2
  1210. | second exception filename
  1211. |
  1212. | strerror
  1213. | exception strerror
  1214. |
  1215. | winerror
  1216. | Win32 exception code
  1217. |
  1218. | ----------------------------------------------------------------------
  1219. | Methods inherited from builtins.BaseException:
  1220. |
  1221. | __delattr__(self, name, /)
  1222. | Implement delattr(self, name).
  1223. |
  1224. | __getattribute__(self, name, /)
  1225. | Return getattr(self, name).
  1226. |
  1227. | __repr__(self, /)
  1228. | Return repr(self).
  1229. |
  1230. | __setattr__(self, name, value, /)
  1231. | Implement setattr(self, name, value).
  1232. |
  1233. | __setstate__(...)
  1234. |
  1235. | with_traceback(...)
  1236. | Exception.with_traceback(tb) --
  1237. | set self.__traceback__ to tb and return self.
  1238. |
  1239. | ----------------------------------------------------------------------
  1240. | Data descriptors inherited from builtins.BaseException:
  1241. |
  1242. | __cause__
  1243. | exception cause
  1244. |
  1245. | __context__
  1246. | exception context
  1247. |
  1248. | __dict__
  1249. |
  1250. | __suppress_context__
  1251. |
  1252. | __traceback__
  1253. |
  1254. | args
  1255.  
  1256. class SMTP_SSL(SMTP)
  1257. | This is a subclass derived from SMTP that connects over an SSL
  1258. | encrypted socket (to use this class you need a socket module that was
  1259. | compiled with SSL support). If host is not specified, '' (the local
  1260. | host) is used. If port is omitted, the standard SMTP-over-SSL port
  1261. | (465) is used. local_hostname and source_address have the same meaning
  1262. | as they do in the SMTP class. keyfile and certfile are also optional -
  1263. | they can contain a PEM formatted private key and certificate chain file
  1264. | for the SSL connection. context also optional, can contain a
  1265. | SSLContext, and is an alternative to keyfile and certfile; If it is
  1266. | specified both keyfile and certfile must be None.
  1267. |
  1268. | Method resolution order:
  1269. | SMTP_SSL
  1270. | SMTP
  1271. | builtins.object
  1272. |
  1273. | Methods defined here:
  1274. |
  1275. | __init__(self, host='', port=0, local_hostname=None, keyfile=None, certfile=None, timeout=<object object at 0x00CD8D70>, source_address=None, context=None)
  1276. | Initialize a new instance.
  1277. |
  1278. | If specified, `host' is the name of the remote host to which to
  1279. | connect. If specified, `port' specifies the port to which to connect.
  1280. | By default, smtplib.SMTP_PORT is used. If a host is specified the
  1281. | connect method is called, and if it returns anything other than a
  1282. | success code an SMTPConnectError is raised. If specified,
  1283. | `local_hostname` is used as the FQDN of the local host in the HELO/EHLO
  1284. | command. Otherwise, the local hostname is found using
  1285. | socket.getfqdn(). The `source_address` parameter takes a 2-tuple (host,
  1286. | port) for the socket to bind to as its source address before
  1287. | connecting. If the host is '' and port is 0, the OS default behavior
  1288. | will be used.
  1289. |
  1290. | ----------------------------------------------------------------------
  1291. | Data and other attributes defined here:
  1292. |
  1293. | default_port = 465
  1294. |
  1295. | ----------------------------------------------------------------------
  1296. | Methods inherited from SMTP:
  1297. |
  1298. | __enter__(self)
  1299. |
  1300. | __exit__(self, *args)
  1301. |
  1302. | auth(self, mechanism, authobject, *, initial_response_ok=True)
  1303. | Authentication command - requires response processing.
  1304. |
  1305. | 'mechanism' specifies which authentication mechanism is to
  1306. | be used - the valid values are those listed in the 'auth'
  1307. | element of 'esmtp_features'.
  1308. |
  1309. | 'authobject' must be a callable object taking a single argument:
  1310. |
  1311. | data = authobject(challenge)
  1312. |
  1313. | It will be called to process the server's challenge response; the
  1314. | challenge argument it is passed will be a bytes. It should return
  1315. | bytes data that will be base64 encoded and sent to the server.
  1316. |
  1317. | Keyword arguments:
  1318. | - initial_response_ok: Allow sending the RFC 4954 initial-response
  1319. | to the AUTH command, if the authentication methods supports it.
  1320. |
  1321. | auth_cram_md5(self, challenge=None)
  1322. | Authobject to use with CRAM-MD5 authentication. Requires self.user
  1323. | and self.password to be set.
  1324. |
  1325. | auth_login(self, challenge=None)
  1326. | Authobject to use with LOGIN authentication. Requires self.user and
  1327. | self.password to be set.
  1328. |
  1329. | auth_plain(self, challenge=None)
  1330. | Authobject to use with PLAIN authentication. Requires self.user and
  1331. | self.password to be set.
  1332. |
  1333. | close(self)
  1334. | Close the connection to the SMTP server.
  1335. |
  1336. | connect(self, host='localhost', port=0, source_address=None)
  1337. | Connect to a host on a given port.
  1338. |
  1339. | If the hostname ends with a colon (`:') followed by a number, and
  1340. | there is no port specified, that suffix will be stripped off and the
  1341. | number interpreted as the port number to use.
  1342. |
  1343. | Note: This method is automatically invoked by __init__, if a host is
  1344. | specified during instantiation.
  1345. |
  1346. | data(self, msg)
  1347. | SMTP 'DATA' command -- sends message data to server.
  1348. |
  1349. | Automatically quotes lines beginning with a period per rfc821.
  1350. | Raises SMTPDataError if there is an unexpected reply to the
  1351. | DATA command; the return value from this method is the final
  1352. | response code received when the all data is sent. If msg
  1353. | is a string, lone '\r' and '\n' characters are converted to
  1354. | '\r\n' characters. If msg is bytes, it is transmitted as is.
  1355. |
  1356. | docmd(self, cmd, args='')
  1357. | Send a command, and return its response code.
  1358. |
  1359. | ehlo(self, name='')
  1360. | SMTP 'ehlo' command.
  1361. | Hostname to send for this command defaults to the FQDN of the local
  1362. | host.
  1363. |
  1364. | ehlo_or_helo_if_needed(self)
  1365. | Call self.ehlo() and/or self.helo() if needed.
  1366. |
  1367. | If there has been no previous EHLO or HELO command this session, this
  1368. | method tries ESMTP EHLO first.
  1369. |
  1370. | This method may raise the following exceptions:
  1371. |
  1372. | SMTPHeloError The server didn't reply properly to
  1373. | the helo greeting.
  1374. |
  1375. | expn(self, address)
  1376. | SMTP 'expn' command -- expands a mailing list.
  1377. |
  1378. | getreply(self)
  1379. | Get a reply from the server.
  1380. |
  1381. | Returns a tuple consisting of:
  1382. |
  1383. | - server response code (e.g. '250', or such, if all goes well)
  1384. | Note: returns -1 if it can't read response code.
  1385. |
  1386. | - server response string corresponding to response code (multiline
  1387. | responses are converted to a single, multiline string).
  1388. |
  1389. | Raises SMTPServerDisconnected if end-of-file is reached.
  1390. |
  1391. | has_extn(self, opt)
  1392. | Does the server support a given SMTP service extension?
  1393. |
  1394. | helo(self, name='')
  1395. | SMTP 'helo' command.
  1396. | Hostname to send for this command defaults to the FQDN of the local
  1397. | host.
  1398. |
  1399. | help(self, args='')
  1400. | SMTP 'help' command.
  1401. | Returns help text from server.
  1402. |
  1403. | login(self, user, password, *, initial_response_ok=True)
  1404. | Log in on an SMTP server that requires authentication.
  1405. |
  1406. | The arguments are:
  1407. | - user: The user name to authenticate with.
  1408. | - password: The password for the authentication.
  1409. |
  1410. | Keyword arguments:
  1411. | - initial_response_ok: Allow sending the RFC 4954 initial-response
  1412. | to the AUTH command, if the authentication methods supports it.
  1413. |
  1414. | If there has been no previous EHLO or HELO command this session, this
  1415. | method tries ESMTP EHLO first.
  1416. |
  1417. | This method will return normally if the authentication was successful.
  1418. |
  1419. | This method may raise the following exceptions:
  1420. |
  1421. | SMTPHeloError The server didn't reply properly to
  1422. | the helo greeting.
  1423. | SMTPAuthenticationError The server didn't accept the username/
  1424. | password combination.
  1425. | SMTPNotSupportedError The AUTH command is not supported by the
  1426. | server.
  1427. | SMTPException No suitable authentication method was
  1428. | found.
  1429. |
  1430. | mail(self, sender, options=[])
  1431. | SMTP 'mail' command -- begins mail xfer session.
  1432. |
  1433. | This method may raise the following exceptions:
  1434. |
  1435. | SMTPNotSupportedError The options parameter includes 'SMTPUTF8'
  1436. | but the SMTPUTF8 extension is not supported by
  1437. | the server.
  1438. |
  1439. | noop(self)
  1440. | SMTP 'noop' command -- doesn't do anything :>
  1441. |
  1442. | putcmd(self, cmd, args='')
  1443. | Send a command to the server.
  1444. |
  1445. | quit(self)
  1446. | Terminate the SMTP session.
  1447. |
  1448. | rcpt(self, recip, options=[])
  1449. | SMTP 'rcpt' command -- indicates 1 recipient for this mail.
  1450. |
  1451. | rset(self)
  1452. | SMTP 'rset' command -- resets session.
  1453. |
  1454. | send(self, s)
  1455. | Send `s' to the server.
  1456. |
  1457. | send_message(self, msg, from_addr=None, to_addrs=None, mail_options=[], rcpt_options={})
  1458. | Converts message to a bytestring and passes it to sendmail.
  1459. |
  1460. | The arguments are as for sendmail, except that msg is an
  1461. | email.message.Message object. If from_addr is None or to_addrs is
  1462. | None, these arguments are taken from the headers of the Message as
  1463. | described in RFC 2822 (a ValueError is raised if there is more than
  1464. | one set of 'Resent-' headers). Regardless of the values of from_addr and
  1465. | to_addr, any Bcc field (or Resent-Bcc field, when the Message is a
  1466. | resent) of the Message object won't be transmitted. The Message
  1467. | object is then serialized using email.generator.BytesGenerator and
  1468. | sendmail is called to transmit the message. If the sender or any of
  1469. | the recipient addresses contain non-ASCII and the server advertises the
  1470. | SMTPUTF8 capability, the policy is cloned with utf8 set to True for the
  1471. | serialization, and SMTPUTF8 and BODY=8BITMIME are asserted on the send.
  1472. | If the server does not support SMTPUTF8, an SMPTNotSupported error is
  1473. | raised. Otherwise the generator is called without modifying the
  1474. | policy.
  1475. |
  1476. | sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[])
  1477. | This command performs an entire mail transaction.
  1478. |
  1479. | The arguments are:
  1480. | - from_addr : The address sending this mail.
  1481. | - to_addrs : A list of addresses to send this mail to. A bare
  1482. | string will be treated as a list with 1 address.
  1483. | - msg : The message to send.
  1484. | - mail_options : List of ESMTP options (such as 8bitmime) for the
  1485. | mail command.
  1486. | - rcpt_options : List of ESMTP options (such as DSN commands) for
  1487. | all the rcpt commands.
  1488. |
  1489. | msg may be a string containing characters in the ASCII range, or a byte
  1490. | string. A string is encoded to bytes using the ascii codec, and lone
  1491. | \r and \n characters are converted to \r\n characters.
  1492. |
  1493. | If there has been no previous EHLO or HELO command this session, this
  1494. | method tries ESMTP EHLO first. If the server does ESMTP, message size
  1495. | and each of the specified options will be passed to it. If EHLO
  1496. | fails, HELO will be tried and ESMTP options suppressed.
  1497. |
  1498. | This method will return normally if the mail is accepted for at least
  1499. | one recipient. It returns a dictionary, with one entry for each
  1500. | recipient that was refused. Each entry contains a tuple of the SMTP
  1501. | error code and the accompanying error message sent by the server.
  1502. |
  1503. | This method may raise the following exceptions:
  1504. |
  1505. | SMTPHeloError The server didn't reply properly to
  1506. | the helo greeting.
  1507. | SMTPRecipientsRefused The server rejected ALL recipients
  1508. | (no mail was sent).
  1509. | SMTPSenderRefused The server didn't accept the from_addr.
  1510. | SMTPDataError The server replied with an unexpected
  1511. | error code (other than a refusal of
  1512. | a recipient).
  1513. | SMTPNotSupportedError The mail_options parameter includes 'SMTPUTF8'
  1514. | but the SMTPUTF8 extension is not supported by
  1515. | the server.
  1516. |
  1517. | Note: the connection will be open even after an exception is raised.
  1518. |
  1519. | Example:
  1520. |
  1521. | >>> import smtplib
  1522. | >>> s=smtplib.SMTP("localhost")
  1523. | >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"]
  1524. | >>> msg = '''\
  1525. | ... From: Me@my.org
  1526. | ... Subject: testin'...
  1527. | ...
  1528. | ... This is a test '''
  1529. | >>> s.sendmail("me@my.org",tolist,msg)
  1530. | { "three@three.org" : ( 550 ,"User unknown" ) }
  1531. | >>> s.quit()
  1532. |
  1533. | In the above example, the message was accepted for delivery to three
  1534. | of the four addresses, and one was rejected, with the error code
  1535. | 550. If all addresses are accepted, then the method will return an
  1536. | empty dictionary.
  1537. |
  1538. | set_debuglevel(self, debuglevel)
  1539. | Set the debug output level.
  1540. |
  1541. | A non-false value results in debug messages for connection and for all
  1542. | messages sent to and received from the server.
  1543. |
  1544. | starttls(self, keyfile=None, certfile=None, context=None)
  1545. | Puts the connection to the SMTP server into TLS mode.
  1546. |
  1547. | If there has been no previous EHLO or HELO command this session, this
  1548. | method tries ESMTP EHLO first.
  1549. |
  1550. | If the server supports TLS, this will encrypt the rest of the SMTP
  1551. | session. If you provide the keyfile and certfile parameters,
  1552. | the identity of the SMTP server and client can be checked. This,
  1553. | however, depends on whether the socket module really checks the
  1554. | certificates.
  1555. |
  1556. | This method may raise the following exceptions:
  1557. |
  1558. | SMTPHeloError The server didn't reply properly to
  1559. | the helo greeting.
  1560. |
  1561. | verify(self, address)
  1562. | SMTP 'verify' command -- checks for address validity.
  1563. |
  1564. | vrfy = verify(self, address)
  1565. | SMTP 'verify' command -- checks for address validity.
  1566. |
  1567. | ----------------------------------------------------------------------
  1568. | Data descriptors inherited from SMTP:
  1569. |
  1570. | __dict__
  1571. | dictionary for instance variables (if defined)
  1572. |
  1573. | __weakref__
  1574. | list of weak references to the object (if defined)
  1575. |
  1576. | ----------------------------------------------------------------------
  1577. | Data and other attributes inherited from SMTP:
  1578. |
  1579. | debuglevel = 0
  1580. |
  1581. | does_esmtp = 0
  1582. |
  1583. | ehlo_msg = 'ehlo'
  1584. |
  1585. | ehlo_resp = None
  1586. |
  1587. | file = None
  1588. |
  1589. | helo_resp = None
  1590.  
  1591. FUNCTIONS
  1592. quoteaddr(addrstring)
  1593. Quote a subset of the email addresses defined by RFC 821.
  1594.  
  1595. Should be able to handle anything email.utils.parseaddr can handle.
  1596.  
  1597. quotedata(data)
  1598. Quote data for email.
  1599.  
  1600. Double leading '.', and change Unix newline '\n', or Mac '\r' into
  1601. Internet CRLF end-of-line.
  1602.  
  1603. DATA
  1604. __all__ = ['SMTPException', 'SMTPServerDisconnected', 'SMTPResponseExc...
  1605.  
  1606. FILE
  1607. c:\users\alexqq11\appdata\local\programs\python\python35-32\lib\smtplib.py
  1608.  
  1609.  
  1610. >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement