def __init__(self, laddr, raddr, uilogger): SMTPServer.__init__(self, laddr, raddr) self.uilogger = uilogger self.ib_clients = dict() # a dict to reference different client by account id self.em_clients = list() # list of emails only clients self.ems = None # email sender object self.slack = None # slack client # Retrieve application config from app.yml to initialize emailsender and slack with open('conf/app.yml', 'r') as cf: conf = yaml.load(cf, Loader=yaml.FullLoader) if "email_sender" in conf: self.ems = EmailSender( conf["email_sender"]["smtp_server"], conf["email_sender"]["smtp_port"], conf["email_sender"]["sender"], self.uilogger ) if "slack" in conf: self.slack = Slack( conf['slack']['webhook_path'], url=conf['slack']['webhook_url'], channel=conf['slack']['channel'], username=conf['slack']['username'], icon=conf['slack']['icon'] )
def __init__(self, *args, **kwargs): SMTPServer.__init__(self, *args, **kwargs) sys.stdout = codecs.getwriter('utf8')(sys.stdout) sys.stderr = codecs.getwriter('utf8')(sys.stderr) print( 'Debug email server is running. Now you can send emails to SMTP localhost:10250.' )
def __init__(self, localaddr, db_config, drop_publisher, cf_options): SMTPServer.__init__(self, localaddr, None) self.drop_publisher = drop_publisher self.db_config = db_config self.db = None self.cf_options = cf_options
def __init__(self, localaddr, db_config, api_url, api_key): SMTPServer.__init__(self, localaddr, None) self.db_config = db_config self.api_url = api_url self.api_key = api_key self.h = Http() self.db = None
def __init__(self, *args, **kwargs): SMTPServer.__init__(self, *args, **kwargs) self.set_reuse_addr() fcntl.fcntl( self.socket.fileno(), fcntl.F_SETFD, fcntl.fcntl(self.socket.fileno(), fcntl.F_GETFD) | fcntl.FD_CLOEXEC) self.data = []
def __init__(self, localaddr, remoteaddr, outputdir, debug=False): '''Initialise''' self.outputdir = outputdir self.debug = debug if not (os.path.exists(outputdir) and os.path.isdir(outputdir)): raise ValueError( 'Provided output dir does not exist or is not a directory') SMTPServer.__init__(self, localaddr, remoteaddr)
def __init__(self, address_or_socket, authenticator=SMTPAuth()): if callable(getattr(address_or_socket, 'listen', None)): asyncore.dispatcher.__init__(self) address_or_socket.setblocking(0) self.set_socket(address_or_socket) else: BaseSMTPServer.__init__(self, address_or_socket, None) self.authenticator = authenticator self.parser = Parser()
def __init__(self, localaddr, remoteaddr): SMTPServer.__init__(self, localaddr, remoteaddr) with open('sendgrid_key', 'r+') as content_file: data = content_file.read().strip() if data is None or data == '': print('No API key set in the file: sendgrid_key') exit(1) print('Sendgrid API key read from storage') self.apikey = data
def __init__(self, localaddr, remoteaddr, output_dir=None, convert=False, log_via=None): SMTPServer.__init__(self, localaddr, None) if not output_dir: output_dir = '.' self.output_dir = output_dir self.convert = convert if not log_via: log_via = 'stdio' self.log_via = log_via
def run(self): try: self.log.clear() server = SMTPServer( (self.conf['smtp']['host'], self.conf['smtp']['port']), None ) server.process_message = self.process_message loop() except KeyboardInterrupt: pass
def publishMessage(self, topic, data): host = self.config.getValue(ConfigConst.SMTP_CLOUD_SECTION, ConfigConst.HOST_KEY) port = self.config.getValue(ConfigConst.SMTP_CLOUD_SECTION, ConfigConst.PORT_KEY) fromAddr = self.config.getValue(ConfigConst.SMTP_CLOUD_SECTION, ConfigConst.FROM_ADDRESS_KEY) toAddr = self.config.getValue(ConfigConst.SMTP_CLOUD_SECTION, ConfigConst.TO_ADDRESS_KEY) authToken = self.config.getValue(ConfigConst.SMTP_CLOUD_SECTION, ConfigConst.USER_AUTH_TOKEN_KEY) msg = MIMEMultipart() msg['From'] = fromAddr msg['To'] = toAddr msg['Subject'] = topic msgBody = str(data) msg.attach(MIMEText(msgBody)) msgText = msg.as_string() SMTPServer = smtplib.SMTP_SSL(host, port) SMTPServer.ehlo() SMTPServer.login(fromAddr, authToken) SMTPServer.sendmail(fromAddr, toAddr, msgText) SMTPServer.close()
def __init__(self, host='127.0.0.1', port=2526): # Initialize the SMTP component. # My face that asyncore doesn't use new style classes! SMTPServer.__init__(self, (host, port), None) # Retrieve the actually-bound socket address. May, in some circumstances, use a reverse DNS name. if self._localaddr[1] == 0: self.address = self.socket.getsockname() else: self.address = (host, port) # Create a place to store messages. self.messages = deque() # Setup threading. self._stop = Event() self._lock = RLock() Thread.__init__(self, name=self.__class__.__name__)
def main(): localaddr = ('localhost', 8080) remoteaddr = ('mail.example.com', 8080) server = SMTPServer(localaddr, remoteaddr, data_size_limit=33554432, map=None, enable_SMTPUTF8=False, decode_data=False)
class BaseMailer(ABC): def __init__(self): smtp_local_host = env_vars['SMTP_LOCAL_HOST'] smtp_local_port = int(env_vars['SMTP_LOCAL_PORT']) smtp_remote_host = env_vars['SMTP_REMOTE_HOST'] smtp_remote_port = int(env_vars['SMTP_REMOTE_PORT']) self.smtp_local_address = (smtp_local_host, smtp_local_port) self.smtp_remote_address = (smtp_remote_host, smtp_remote_port) self.sender_email = env_vars['SENDER_EMAIL'] self.sender_password = env_vars['SENDER_PASSWORD'] self.receiver_email = env_vars['RECEIVER_EMAIL'] self.parsed_data = [] self.initialize_smtp_server() @property @abstractmethod def email_body(self): pass def initialize_smtp_server(self): self.smtp_server = SMTPServer(self.smtp_local_address, self.smtp_remote_address) def send_email(self, parsed_data): self.parsed_data = parsed_data context = create_default_context() with SMTP_SSL('smtp.gmail.com', 465, context=context) as server: server.login(self.sender_email, self.sender_password) server.sendmail(self.sender_email, self.receiver_email, self.email_body) server.quit() self.smtp_server.close()
def __init__(self, logger, localaddr, remoteaddr): self.logger = logger SMTPServer.__init__(self, localaddr, remoteaddr)
def __init__(self, localaddr, remoteaddr, queue): self._localaddr = localaddr self._remoteaddr = remoteaddr self._queue = queue SMTPServer.__init__(self, localaddr, remoteaddr)
def run(self): SMTPServer.__init__(self, (self.host, self.port), None) try: asyncore.loop() except KeyboardInterrupt: pass
def __init__(self, *args, **kwargs): self.store = kwargs.pop('store') SMTPServer.__init__(self, *args, **kwargs)
def __init__(self, localaddr, remoteaddr): SMTPServer.__init__(self, localaddr, remoteaddr) self.processor = RaindropEmailProcessor() self.hbase = RaindropHBaseClient()
def __init__(self, localaddr, remoteaddr, fail, channel): SMTPServer.__init__(self, localaddr, remoteaddr) self.fail = fail self.channel = channel
def __init__(self, outgoing, *args, **kwargs): SMTPServer.__init__(self, *args, **kwargs) self.outgoing = outgoing self.log = open("IncomingServer.log", "w")
def __init__(self, *args, **kwargs): threading.Thread.__init__(self) SMTPServer.__init__(self, *args, **kwargs) self.active_lock = threading.Lock() self.active = False self.daemon = True
def initialize_smtp_server(self): self.smtp_server = SMTPServer(self.smtp_local_address, self.smtp_remote_address)
def __init__(self, localaddr, remoteaddr, maildir): SMTPServer.__init__(self, localaddr, remoteaddr) self.maildir = maildir
def __init__(self, path, *args, **kwargs): self.path = path self.counter = count(1) # smtpd.SMTPServer is still on old-school class on 2.7 SMTPServer.__init__(self, *args, **kwargs)
def __init__(self, localaddr, remoteaddr, logger): SMTPServer.__init__(self, localaddr, remoteaddr) self.log = logger
def __init__(self, localaddr, queue): SMTPServer.__init__(self, localaddr, None) self.queue = queue
def __init__(self, localaddr, remoteaddr): SMTPServer.__init__(self, localaddr, remoteaddr)
def __init__(self): SMTPServer.__init__(self, ('0.0.0.0', 25), None)
def __init__(self, localaddr, remoteaddr, queue): SMTPServer.__init__(self, localaddr, remoteaddr) self.queue = queue
def __init__(self, output_connection): SMTPServer.__init__(self, ('localhost', 8001), None) self.output_connection = output_connection
def __init__(self, *args, **kwargs): SMTPServer.__init__(self, *args, **kwargs) sys.stdout = codecs.getwriter('utf8')(sys.stdout) sys.stderr = codecs.getwriter('utf8')(sys.stderr) print 'Debug email server is running. Now you can send emails to SMTP localhost:10250.'
def __init__(self, host, port): self.msgs = [] SMTPServer.__init__(self, (host, port), None)
def __init__(self, localaddr, remoteaddr): SMTPServer.__init__(self, localaddr, remoteaddr) self.number = 0
def __init__(self, localaddr, remoteaddr): SMTPServer.__init__(self, localaddr, remoteaddr) self.mboxes = defaultdict(Mailbox)
def __init__(self, localaddr, remoteaddr, saveobj, logobj): self.capture = saveobj self.message = logobj SMTPServer.__init__(self, localaddr, remoteaddr)
def __init__(self, app, bindaddr, port): SMTPServer.__init__(self, (bindaddr, port), None) self.app = app
def __init__(self): localaddr = (settings['lmtpd_host'], settings['lmtpd_port']) SMTPServer.__init__(self, localaddr, None) self.db_connect()
def __init__(self, localaddr, handler): SMTPServer.__init__(self, localaddr, None) self.handler = handler
def __init__(self, *args, **kwargs): SMTPServer.__init__(self, *args, **kwargs) self.callbacks = []
def __init__(self, *args, **kwargs): SMTPServer.__init__(self, *args, **kwargs) #TODO: lock self._messages? self._messages = []
def __init__(self, call_back_function=None): SMTPServer.__init__(self, ('localhost', 8025), (None, 0)) self.call_back_function = call_back_function
def __init__(self, localaddr, queue): SMTPServer.__init__(self, localaddr, None, decode_data=True) self.queue = queue