示例#1
0
    def send_activation_link(email, domain, days, uuid):
        '''Send link to email address via SES.'''
        link = '%s/confirm.html?user=%s&uuid=%s' % (FRONTEND_URL, email, uuid)
        body = '''Hello,

you have requested to be notified if and when the SSL certificate for domain "%s"
will expire in the following %d days.

To enable the service, please verify your email address clicking on the following link:

%s

-- 
%s
''' % (domain, days, link, DOMAINNAME)
        try:
            LOGGER.info('sending activation link %s for domain %s', link,
                        domain)
            send_ses_email(email, 'Confirm subscription to %s' % DOMAINNAME,
                           body, 'ValidationLink')
            return {
                'response':
                'Please check your emails to confirm your subscription'
            }
        except ClientError:
            LOGGER.exception('exception sending confirmation email to %s',
                             email)
            return {
                'errorMessage':
                'Error sending confirmation email, '
                'please ensure your email address is valid and that '
                'your mailbox is not full'
            }
示例#2
0
    def check_and_send_alert(record):
        '''Send alert email if sslexpired check has alerts.'''
        if not ('domain' in record and 'days' in record):
            err = 'error: wrong record format: %s' % record
            print(err)
            return err

        try:
            result = Checker.check_sslexpired(record['domain'], record['days'])
        # pylint: disable=broad-except
        except Exception:
            msg = 'exceptions invoking %s' % SSLEXPIRED_API_URL
            LOGGER.exception(msg)
            return {'errorMessage': msg}

        if result.get('err'):
            LOGGER.error('errors found processing record: %s', result)

        if 'alert' in result:
            LOGGER.info('sending alert to %(email)s for domain %(domain)s', record)
            lambda_mailer('send_alert', record['email'], record['domain'],
                          result['response'], record['uuid'])
        else:
            LOGGER.info('domain %(domain)s for %(email)s is not in alert state', record)

        return {'response': 'ok'}
示例#3
0
    def send_alert(email, domain, message, uuid):
        '''Send alert email via SES.'''
        link = '%s/unsubscribe.html?user=%s&uuid=%s' % (FRONTEND_URL, email,
                                                        uuid)
        body = '''%s

You will receive this alert every day until a new certificate has been issued to replace the current one.

To disable the alert, unsubscribe following this link: %s

-- 
%s
''' % (message, link, DOMAINNAME)
        try:
            LOGGER.info('sending alert message for domain %s to %s', domain,
                        email)
            send_ses_email(email, 'SSL alert for domain %s' % domain, body,
                           'ExpiryAlert')
            return {'response': 'email sent successfully'}
        except ClientError:
            LOGGER.exception('exception sending alert email to %s', email)
            return {
                'errorMessage':
                'internal error delivering email to the '
                'email system, please try again later'
            }
示例#4
0
 def send_report():
     '''Get a report from CloudWatch logs and S3, send via email.'''
     report = Reporter.get_report(exclude_regexp=r'^(START |END |REPORT |\[INFO\])')
     if report:
         return lambda_mailer('send_report', report)
     LOGGER.info('empty report')
     return {'response': 'empty report'}
示例#5
0
 def scan_and_notify_alerts_queue():
     '''Trigger a lambda checker for each validated user.'''
     counter = 0
     for record in lambda_db('get_validated_users').get('response'):
         lambda_checker('check_and_send_alert', record)
         counter += 1
     msg = '%d record(s) processed successfully' % counter
     LOGGER.info(msg)
     return {'response': msg}
示例#6
0
 def send_report(report):
     '''Send daily report via SES.'''
     try:
         LOGGER.info('sending report mail')
         send_ses_email(REPORT_TO_EMAIL,
                        'Daily report',
                        report,
                        tag='DailyReport')
         return {'response': 'report sent via email'}
     except ClientError:
         LOGGER.exception('exception sending feedback email')
         return {'errorMessage': 'Internal error sending report email'}
示例#7
0
 def send_feedback(content):
     '''Send feedback data to email address via SES.'''
     try:
         LOGGER.info('sending feedback mail')
         send_ses_email(FEEDBACK_EMAIL,
                        'Form feedback entry',
                        content,
                        tag='Feedback')
         return {'response': 'thank you for your submission'}
     except ClientError:
         LOGGER.exception('exception sending feedback email')
         return {
             'errorMessage': 'Error sending feedback email, '
             'please try later'
         }
示例#8
0
 def check_sslexpired(domain, days=None):
     '''Return response from sslexpired.info API.'''
     url = '%s/%s%s' % (SSLEXPIRED_API_URL, domain,
                        ('?days=%s' % days) if days else '')
     LOGGER.info('invoking %s', url)
     return json.load(urllib.request.urlopen(url))