def METHOD_NAME(self):
    # try:
    if self.pw is not None:
        try:
            smtp_server = smtplib.SMTP(self.host, self.port)
            smtp_server.starttls()
        except smtplib.SMTPNotSupportedError:
            self.logger.info(f"The server {self.host}:{self.port} does not support the STARTTLS extension.")
            if self.cert_required:
                context = create_default_context(cafile=self.ca_file)
            else:
                context = None
            smtp_server = smtplib.SMTP_SSL(self.host, self.port, context=context)
        smtp_server.ehlo()
        if self.user is not None:
            smtp_server.login(self.user, self.pw)
        else:
            smtp_server.login(self.sender, self.pw)
    else:
        smtp_server = smtplib.SMTP(self.host, self.port)
    return smtp_server
    # except Exception as err:
    # traceback.print_tb(err.__traceback__)
    # self.logger.warning(err)