Introduction
Hello, I’m Kuruma from the Platform Application Division of the Money Forward CTO Office. I’m primarily responsible for the development and operation of our email delivery platform and some microservices.
Most of our in-house products use this email delivery platform to send emails to users. For more details about our email delivery platform, please refer to this article we posted earlier(note: the linked article is in Japanese).
In October 2023, Google announced Email sender guidelines. These new guidelines were implemented in stages throughout 2024 and have had a significant impact, especially on high-volume email senders.
One of the most notable requirements is the mandatory implementation of the “One-Click Unsubscribe” feature for marketing and promotional emails. Failure to implement this feature by the deadline risks emails being rejected or delivered to recipients’ spam folders.
To meet this requirement, our team undertook the development of the One-Click Unsubscribe feature.
In this article, I’ll introduce the architecture and technical background of our implementation of this feature.
What is One-Click Unsubscribe?
One-Click Unsubscribe is a feature that allows email recipients to easily and quickly opt out of email subscriptions.
This functionality is specified in RFC8058 and is implemented by setting specific email headers.
An email with the following two headers complies with RFC8058:
- List-Unsubscribe-Post: List-Unsubscribe=One-Click
- List-Unsubscribe: < {HTTPS URI of the server receiving the unsubscribe request} >
By adding these headers, email client applications like Gmail display an “Unsubscribe” button similar to the one shown below:
When a recipient clicks this button, an HTTP POST request is automatically sent to the URI specified in the List-Unsubscribe header.
This allows recipients to unsubscribe from email distributions with a single click, without going through complex procedures.
This mechanism results in a better user experience, fewer spam reports and reduced reputation damage.
Requirements and Issues
In implementing the One-Click Unsubscribe feature, we organized the technical requirements and our company-specific issues.
Technical Requirements
To realize the One-Click Unsubscribe feature, the following elements are necessary:
- Server to process unsubscribe requests
- Mechanism to manage email subscriptions for each user
- Feature to set List-Unsubscribe-Post and List-Unsubscribe in email headers
Company-Specific Issues
One-Click Unsubscribe for Multiple Products
Our company comprises multiple divisions developing diverse products, all of which utilize our email delivery platform. The email delivery platform itself should not manage user data including subscription preferences. Instead, each product maintains its own email subscription.
We needed to design a solution that would work seamlessly with our email delivery platform while respecting the autonomy of each product’s existing subscription management processes.
Development Within a Strict Deadline
We were required to complete the development within a limited timeframe to meet Google’s new sender guidelines implementation deadline (initially set for February 2024, later extended to June 2024). Our company sends over 250 million emails monthly, so failing to complete the development in time risked a significant number of emails not reaching their recipients, potentially causing severe business impact. Therefore, efficient development and rapid deployment were crucial.
Approach
Based on the aforementioned issues and technical requirements, we adopted the following approach.
Component Design
Email delivery platform side
The email delivery platform plays a central role in the One-Click Unsubscribe feature. It implements a centralized unsubscribe processing system, which is responsible for:
- Dynamic One-Click Unsubscribe link generation and Email header setting
- Generating links by encrypting necessary information such as email subscription management system identifier, email and recipient details during email sending
- Setting email headers (List-Unsubscribe-Post and List-Unsubscribe) with the generated link and sending the email
- Unsubscribe request handling
- Receiving unsubscribe requests
- Notifying the appropriate product’s email subscription management system of received requests
Product side
Each product implements its own email subscription management system based on its business logic.
- Managing email subscriptions for each user
- Receiving unsubscribe notifications from the email delivery platform and updating user subscriptions
Advantages
This design offers several advantages:
- Standardization and efficiency: The centralized approach enables uniform security measures and unsubscribe processing across products. The shared infrastructure reduces development overhead and enhances resilience against future specification changes.
- Adaptability: Changes in One-Click Unsubscribe specifications can be accommodated, and new products can be integrated without major modifications to the existing setup.
- Product autonomy: While utilizing the centralized unsubscribe feature, each product maintains independent control over its email subscription management.
Process Flow
The process flow based on our adopted approach is as follows:
- Product: Select target users based on email subscription management system
- Product: Send email request including email subscription management system identifier to the email delivery platform
- Email delivery platform: Generate One-Click Unsubscribe link, insert into email, and send
- User: Click the unsubscribe link
- Email delivery platform: Receive request, notify relevant product’s email subscription management system based on link information
- Product: Update user’s email subscription in the email subscription management system based on the notification
Overall Architecture and Implementation
Based on our adopted approach, we realized the following architecture:
Notifying Multiple Products via Kafka
We utilize Kafka, our existing inter-system communication infrastructure, to transmit unsubscribe information between the email delivery platform and each product.
Kafka is a distributed event streaming platform that allows for communication between systems. For more information, you can visit the official Apache Kafka website.
We prepare individual Kafka topics for each product based on the email subscription management system identifier.
The procedure for a product to use the One-Click Unsubscribe feature is as follows:
- The product registers the topic name and email subscription management system identifier in a configuration file prepared by the email delivery platform.
- When changes to this configuration file are applied, the email delivery platform automatically generates the corresponding Kafka topic.
The email subscription management system identifier is included in the email sending request and used for generating the unsubscribe link.
For unsubscribe information notification, we define a message using Protobuf and send it as binary data to the Kafka topics. This enables efficient data transfer and flexible implementation independent of programming languages. Each product consumes its own topic to receive unsubscribe notifications and performs update processing.
One-Click Unsubscribe Compatible Email Sending Request
We added a function to send One-Click Unsubscribe compatible emails to the existing email sending microservice (gRPC API) already used by products.
Specifically, we added new parameters: the email subscription management system identifier and an email type that can be freely set by the product side. These parameters are used for generating the unsubscribe link.
Unsubscribe Link Generation
We developed a new microservice within the email delivery platform for unsubscribe link generation. This service generates unsubscribe links by encrypting necessary information such as the email subscription management system identifier, email type, and recipient information.
We developed it as a microservice because of its potential use in other email sending systems and its ability to handle link generation related to emails (e.g., email open notification links) in the future.
The generated unsubscribe link includes the URI of the unsubscribe request processing microservice described later.
The email sending microservice uses this link generation microservice to obtain the unsubscribe link, sets appropriate headers, and sends emails.
Unsubscribe Request Processing
We developed a new microservice as well for processing unsubscribe requests. This microservice receives unsubscribe requests from users, decrypts the link, and notifies the appropriate Kafka topic based on the embedded email subscription management system identifier.
We adopted gRPC-Gateway (https://grpc-ecosystem.github.io/grpc-gateway/) for implementation. This is based on the requirement to standardize on gRPC for ease of management, as the entire existing email delivery platform is gRPC-based. Using gRPC Gateway allows us to provide RESTful endpoints that comply with One-Click Unsubscribe specifications while maintaining a consistent gRPC-based implementation internally.
Conclusion
In this article, I’ve detailed the architectural design and technical considerations behind our implementation of the One-Click Unsubscribe feature. Our solution addresses the challenge of integrating this functionality across multiple products, each with its own email subscription management system, while meeting a tight deadline set by Google’s new sender guidelines. By balancing centralized processing on our email delivery platform with product-specific subscription management, we’ve successfully complied with the new requirements without disrupting our existing product ecosystems.
The Money Forward CTO Office is actively recruiting engineers. We are seeking engineers proficient in designing and building reliable, efficient solutions that enhance user experience and support growth. If you’re interested, please check the details at the following
link: https://hrmos.co/pages/moneyforward/jobs/1960606981176266893