code: def from_settings(cls, settings, prefix='mail.'):
          
          settings = settings or {}
  
          kwarg_names = [prefix + k for k in (
                         'host', 'port', 'username',
                         'password', 'tls', 'ssl', 'keyfile',
                         'certfile', 'queue_path', 'debug', 'default_sender')]
  
          size = len(prefix)
  
          kwargs = dict(((k[size:], settings[k]) for k in settings.keys() if
                          k in kwarg_names))
  
          for key in ('tls', 'ssl'):
              val = kwargs.get(key)
              if val:
                  kwargs[key] = asbool(val)
  
          return cls(**kwargs)
docs: Create a new instance of 'Mailer' from settings dict.
  
          :param settings: a settings dict-like
          :param prefix: prefix separating 'tgext.mailer' settings