Пример #1
0
 def __init__(self, config, mode=''):
     self.cfg = config
     self.mode = mode
     
     if not self.mode:
         raise Exception('no mode given')
     elif (self.mode == 'sms'):
         from smsutil import Sender
     elif (self.mode == 'email'):
         from emailutil import Sender
     else:
         raise Exception('mode %s not supported' % headers['mode'])
     
     self.msg_send = Sender(self.cfg)
Пример #2
0
class MsgSender:
    def __init__(self, config, mode=''):
        self.cfg = config
        self.mode = mode
        
        if not self.mode:
            raise Exception('no mode given')
        elif (self.mode == 'sms'):
            from smsutil import Sender
        elif (self.mode == 'email'):
            from emailutil import Sender
        else:
            raise Exception('mode %s not supported' % headers['mode'])
        
        self.msg_send = Sender(self.cfg)
    
    def process(self, contact, headers, text_content, attachments):
        if not contact:
            raise Exception('no recipient given')
        if self.msg_send.send_message(contact, headers, text_content, attachments):
            log.info('sent to %s' % contact)