def send(event_type, message, targets, options, **kwargs): """ Configures all Lemur email messaging :param event_type: :param options: """ subject = 'Notification: Lemur' if event_type == 'expiration': subject = 'Notification: SSL Certificate Expiration ' # jinja template depending on type template = env.get_template('{}.html'.format(event_type)) body = template.render(dict(messages=message, hostname=current_app.config.get('LEMUR_HOSTNAME'))) s_type = current_app.config.get("LEMUR_EMAIL_SENDER", 'ses').lower() if s_type == 'ses': conn = boto.connect_ses() conn.send_email(current_app.config.get("LEMUR_EMAIL"), subject, body, targets, format='html') elif s_type == 'smtp': msg = Message(subject, recipients=targets) msg.body = "" # kinda a weird api for sending html emails msg.html = body smtp_mail.send(msg) else: current_app.logger.error("No mail carrier specified, notification emails were not able to be sent!")
def send_via_ses(subject, body, targets): """ Attempts to deliver email notification via SES service. :param subject: :param body: :param targets: :return: """ msg = Message(subject, recipients=targets) msg.body = "" # kinda a weird api for sending html emails msg.html = body smtp_mail.send(msg)
def send_via_smtp(subject, body, targets): """ Attempts to deliver email notification via SES service. :param subject: :param body: :param targets: :return: """ msg = Message(subject, recipients=targets, sender=current_app.config.get("LEMUR_EMAIL")) msg.body = "" # kinda a weird api for sending html emails msg.html = body smtp_mail.send(msg)
def send(event_type, message, targets, options, **kwargs): """ Configures all Lemur email messaging :param event_type: :param options: """ subject = 'Notification: Lemur' if event_type == 'expiration': subject = 'Notification: SSL Certificate Expiration ' # jinja template depending on type template = env.get_template('{}.html'.format(event_type)) body = template.render( dict(messages=message, hostname=current_app.config.get('LEMUR_HOSTNAME'))) s_type = current_app.config.get("LEMUR_EMAIL_SENDER", 'ses').lower() if s_type == 'ses': conn = boto.connect_ses() conn.send_email(current_app.config.get("LEMUR_EMAIL"), subject, body, targets, format='html') elif s_type == 'smtp': msg = Message(subject, recipients=targets) msg.body = "" # kinda a weird api for sending html emails msg.html = body smtp_mail.send(msg) else: current_app.logger.error( "No mail carrier specified, notification emails were not able to be sent!" )