def send_expiring_deployed_certificate_notifications(certificates):
    """
    Send an email to the owner of all provided certificates indicating that the certs are still deployed
    but expiring soon.
    """
    success = failure = 0
    notification_type = "expiring_deployed_certificate"
    security_email = current_app.config.get("LEMUR_SECURITY_TEAM_EMAIL")

    for owner, owner_certs in certificates:
        notification_data = []
        # eventually we also want to use the options configured on the cert's notification(s) to notify the owner
        # for now, we'll just email the security team
        email_recipients = security_email
        for certificate, domains_and_ports in owner_certs:
            cert_data = certificate_notification_output_schema.dump(certificate).data
            # we add the domain info into the cert dump in order to reuse existing common email formatting logic
            domain_and_port_data = []
            for domain, ports in domains_and_ports.items():
                domain_and_port_data.append({"domain": domain, "ports": ports})
            cert_data["domains_and_ports"] = domain_and_port_data
            notification_data.append(cert_data)
        if send_default_notification(notification_type, notification_data, email_recipients):
            success += 1
        else:
            failure += 1

    return success, failure

    Send an email to the owner of all provided certificates indicating that the certs are still deployed
    but expiring soon.
    
lemur/notifications/messaging.py