lookyloo/lookyloo.py
def send_mail(self, capture_uuid: str, /, email: str='', comment: str='') -> None:
        '''Send an email notification regarding a specific capture'''
        if not get_config('generic', 'enable_mail_notification'):
            return

        redirects = ''
        initial_url = ''
        cache = self.capture_cache(capture_uuid)
        if cache:
            initial_url = cache.url
            if cache.redirects:
                redirects = "Redirects:\n"
                redirects += '\n'.join(cache.redirects)
            else:
                redirects = "No redirects."

        email_config = get_config('generic', 'email')
        msg = EmailMessage()
        msg['From'] = email_config['from']
        if email:
            msg['Reply-To'] = email
        msg['To'] = email_config['to']
        msg['Subject'] = email_config['subject']
        body = get_email_template()
        body = body.format(
            recipient=msg['To'].addresses[0].display_name,
            domain=self.public_domain,
            uuid=capture_uuid,
            initial_url=initial_url,
            redirects=redirects,
            comment=comment,
            sender=msg['From'].addresses[0].display_name,
        )
        msg.set_content(body)
        try:
            s = smtplib.SMTP(email_config['smtp_host'], email_config['smtp_port'])
            s.send_message(msg)
            s.quit()
        except Exception as e:
            self.logger.exception(e)
            self.logger.warning(msg.as_string())
Send an email notification regarding a specific capture
Send an email notification regarding a specific capture
Send an email notification regarding a specific capture
def send_mail(self, capture_uuid: str, /, email: str='', comment: str='') -> None:
        if not get_config('generic', 'enable_mail_notification'):
            return
        redirects = ''
        initial_url = ''
        cache = self.capture_cache(capture_uuid)
        if cache:
            initial_url = cache.url
            if cache.redirects:
                redirects = "Redirects:\n"
                redirects += '\n'.join(cache.redirects)
            else:
                redirects = "No redirects."
        email_config = get_config('generic', 'email')
        msg = EmailMessage()
        msg['From'] = email_config['from']
        if email:
            msg['Reply-To'] = email
        msg['To'] = email_config['to']
        msg['Subject'] = email_config['subject']
        body = get_email_template()
        body = body.format(
            recipient=msg['To'].addresses[0].display_name,
            domain=self.public_domain,
            uuid=capture_uuid,
            initial_url=initial_url,
            redirects=redirects,
            comment=comment,
            sender=msg['From'].addresses[0].display_name,
        )
        msg.set_content(body)
        try:
            s = smtplib.SMTP(email_config['smtp_host'], email_config['smtp_port'])
            s.send_message(msg)
            s.quit()
        except Exception as e:
            self.logger.exception(e)
            self.logger.warning(msg.as_string())
def send_mail ( self , capture_uuid : str , / , email : str = '' , comment : str = '' ) -> None : if not get_config ( 'generic' , 'enable_mail_notification' ) : return redirects = '' initial_url = '' cache = self . capture_cache ( capture_uuid ) if cache : initial_url = cache . url if cache . redirects : redirects = "Redirects:\n" redirects += '\n' . join ( cache . redirects ) else : redirects = "No redirects." email_config = get_config ( 'generic' , 'email' ) msg = EmailMessage ( ) msg [ 'From' ] = email_config [ 'from' ] if email : msg [ 'Reply-To' ] = email msg [ 'To' ] = email_config [ 'to' ] msg [ 'Subject' ] = email_config [ 'subject' ] body = get_email_template ( ) body = body . format ( recipient = msg [ 'To' ] . addresses [ 0 ] . display_name , domain = self . public_domain , uuid = capture_uuid , initial_url = initial_url , redirects = redirects , comment = comment , sender = msg [ 'From' ] . addresses [ 0 ] . display_name , ) msg . set_content ( body ) try : s = smtplib . SMTP ( email_config [ 'smtp_host' ] , email_config [ 'smtp_port' ] ) s . send_message ( msg ) s . quit ( ) except Exception as e : self . logger . exception ( e ) self . logger . warning ( msg . as_string ( ) )
Send an email notification regarding a specific capture
Send an email notification regarding a specific capture
'''Send an email notification regarding a specific capture'''
self
capture_uuid
str
email
str
comment
str