This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SMTPLIB integrate or provide option to use "logging"
Type: enhancement Stage:
Components: email Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, hpkkumar007, pepoluan, r.david.murray
Priority: normal Keywords:

Created on 2020-09-26 18:51 by hpkkumar007, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg377537 - (view) Author: KK Hiraskar (hpkkumar007) Date: 2020-09-26 18:51
Currently "smtplib" is directly printing data to stdout/stderr, and not getting any good way to get this data in to the logs written by "logging"

please provide an option to achieve this.
msg384886 - (view) Author: Pandu E POLUAN (pepoluan) * Date: 2021-01-12 05:02
Will patching smtplib.SMTP._print_debug do?

You can subclass from smtplib.SMTP this way:

class MySMTPClient(smtplib.SMTP):
    def __init__(self, *args, logger=None, **kwargs):
        super().__init__(*args, **kwargs)
        self.logger = logger
    def _print_debug(self, *args):
        if self.logger:
            self.logger.debug(" ".join(args))
        super()._print_debug(*args)
History
Date User Action Args
2022-04-11 14:59:36adminsetgithub: 86034
2021-01-12 05:02:03pepoluansetnosy: + pepoluan
messages: + msg384886
2020-09-26 18:51:05hpkkumar007create