# Path: sshproxy/config.py
# class ConfigSection(object):
# class Config(object):
# class SSHproxyConfigSection(ConfigSection):
#     def __init__(self, config, section):
#     def init_section(self):
#     def get_default(self, option, default=None):
#     def __getitem__(self, option):
#     def __setitem__(self, option, value):
#     def __delitem__(self, option):
#     def keys(self):
#     def has_key(self, option):
#     def get(self, option, default=None, raw=False):
#     def set(self, option, value):
#     def pop(self, option):
#     def items(self):
#     def write(self):
#     def __str__(self):
#     def register(cls, force=False):
#     def register_handler(cls, name, handler, force=False):
#     def get_handler(cls, name):
#     def __init__(self, inifile):
#     def check_mode(self):
#     def __call__(self, section=None):
#     def __getitem__(self, section):
#     def __setitem__(self, section, options):
#     def __delitem__(self, section):
#     def pop(self, section):
#     def keys(self):
#     def has_key(self, section):
#     def defaults(self):
#     def touch(self):
#     def write(self, inifile=None):
#     def __str__(self):
# def path(path):
# 
# Path: sshproxy/util.py
# def istrue(s):
#     if not s:
#         return False
#     istrue = False
#     if s.lower().strip() in ('yes', 'true', 'on', '1'):
#         istrue = True
#     else:
#         try:
#             if int(s) != 0:
#                 istrue = True
#         except ValueError:
#             pass
#     return istrue
# 
# Path: sshproxy/log.py
# def exception(*args):
# 
# Path: sshproxy/registry.py
# def get_class(class_id):
#     return Registry._registry.get(class_id, Dummy)


import smtplib
import types
import socket, os
from sshproxy.config import get_config, ConfigSection
from sshproxy.util import istrue
from sshproxy import log
from sshproxy.registry import get_class
        from datetime import datetime
    def send_email(self):
        """Method which sends email, if there are any problems it raises
        smtplib.SMTPException"""
        
        msg = ""
        msg += "From: %s\n" % self.sender
        msg += "To: %s\n" % ", ".join(self.recipients)
        msg += "Subject: %s\n\n%s" % (self.subject, self.msg)
        try:
            self._connect_to_smtp()
        except (socket.error, socket.herror):
            return False
        result = self._connection.sendmail(self.sender, self.recipients, msg)
        if result:
            errmsg = ""
            for recp in result.keys():
                errmsg += """Server returned error for recipient: %s
                
                %s
                %s
                """ % (recp, result[recp][0], result[recp][1])
            
            raise smtplib.SMTPException, errmsg
        
        self._connection.quit()
        
        return True
        



# Path: sshproxy/config.py
# class ConfigSection(object):
# class Config(object):
# class SSHproxyConfigSection(ConfigSection):
#     def __init__(self, config, section):
#     def init_section(self):
#     def get_default(self, option, default=None):
#     def __getitem__(self, option):
#     def __setitem__(self, option, value):
#     def __delitem__(self, option):
#     def keys(self):
#     def has_key(self, option):
#     def get(self, option, default=None, raw=False):
#     def set(self, option, value):
#     def pop(self, option):
#     def items(self):
#     def write(self):
#     def __str__(self):
#     def register(cls, force=False):
#     def register_handler(cls, name, handler, force=False):
#     def get_handler(cls, name):
#     def __init__(self, inifile):
#     def check_mode(self):
#     def __call__(self, section=None):
#     def __getitem__(self, section):
#     def __setitem__(self, section, options):
#     def __delitem__(self, section):
#     def pop(self, section):
#     def keys(self):
#     def has_key(self, section):
#     def defaults(self):
#     def touch(self):
#     def write(self, inifile=None):
#     def __str__(self):
# def path(path):
# 
# Path: sshproxy/util.py
# def istrue(s):
#     if not s:
#         return False
#     istrue = False
#     if s.lower().strip() in ('yes', 'true', 'on', '1'):
#         istrue = True
#     else:
#         try:
#             if int(s) != 0:
#                 istrue = True
#         except ValueError:
#             pass
#     return istrue
# 
# Path: sshproxy/log.py
# def exception(*args):
# 
# Path: sshproxy/registry.py
# def get_class(class_id):
#     return Registry._registry.get(class_id, Dummy)


# Path: lib/email_notifier/notifier.py
import smtplib
import types
import socket, os
from sshproxy.config import get_config, ConfigSection
from sshproxy.util import istrue
from sshproxy import log
from sshproxy.registry import get_class
        from datetime import datetime

    def send_email(self):
        """Method which sends email, if there are any problems it raises
        smtplib.SMTPException"""
        
        msg = ""
        msg += "From: %s\n" % self.sender
        msg += "To: %s\n" % ", ".join(self.recipients)
        msg += "Subject: %s\n\n%s" % (self.subject, self.msg)
        try:
            self._connect_to_smtp()
        except (socket.error, socket.herror):
            return False
        result = self._connection.sendmail(self.sender, self.recipients, msg)
        if result:
            errmsg = ""
            for recp in result.keys():
                errmsg += """Server returned error for recipient: %s
                
                %s
                %s
                """ % (recp, result[recp][0], result[recp][1])
            
            raise smtplib.SMTPException, errmsg
        
        self._connection.quit()
        
        return True
        



Server = get_class("Server")