Extending Email Providers
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The cursor-free-vip project features an extensible system for integrating various temporary email providers. This system is designed to automate the process of creating new accounts for Cursor by programmatically generating an email address and retrieving the verification code sent to it. The architecture allows developers to add support for new temporary email services with minimal changes to the core registration logic.
This document outlines the architecture of the email provider system, details the contract that new providers must adhere to, and provides a step-by-step guide for extending the system with a new email service.
Sources: cursor_register_manual.py, main.py:444
Core Architecture
The system is built around an abstract base class, EmailTabInterface, which defines a common contract for all email provider implementations. Concrete classes, such as TempMailPlusTab and OneSecMailTab, inherit from this interface and provide the specific logic for interacting with their respective email service APIs.
The EmailController class in cursor_register_manual.py acts as a factory and manager for these providers, selecting and instantiating the appropriate email service based on the application's configuration.
Sources: cursor_register_manual.py:48, email_tabs/email_tab_interface.py:9, email_tabs/tempmail_plus_tab.py:17, email_tabs/one_sec_mail_tab.py:16
Class Diagram
The following diagram illustrates the relationship between the interface and its concrete implementations.
The EmailTabInterface Contract
Any class that provides temporary email functionality must inherit from EmailTabInterface and implement its abstract methods. This ensures a consistent API for the rest of the application to use.
Sources: email_tabs/email_tab_interface.py:9-20
| Method | Description |
|---|---|
create_email(timeout) | Creates or retrieves a temporary email address from the provider. It must return the email address as a string. |
get_verification_code(timeout) | Fetches the verification code from the email inbox. It should handle retries and timeouts, returning the code as a string. |
Sources: email_tabs/email_tab_interface.py:15-20
Configuration
Email providers can be configured via the config.ini file. The system uses this configuration to determine which provider to use and to pass necessary credentials or settings. For example, the TempMailPlusTab provider uses a dedicated [TempMailPlus] section.
Sources: config.py:168-172, email_tabs/tempmail_plus_tab.py:27-44
Example: [TempMailPlus] Configuration
This section in config.ini controls the TempMailPlusTab provider.
| Option | Type | Description | Default Value |
|---|---|---|---|
enabled | boolean | If true, the EmailController will consider this provider for use. | false |
email | string | A specific mailto.plus email address to use. If blank, one is not used. | '' |
epin | string | The API key or pin required for the mailto.plus service. | '' |
Sources: config.py:169-172
Integration into the Signup Process
The EmailController class in cursor_register_manual.py is the primary consumer of the email provider services. Its main responsibility is to select and manage the lifecycle of an email provider during the account registration flow.
Provider Selection
The get_email_service method within EmailController contains the logic for selecting a provider. It checks the config.ini file to see if TempMailPlus is enabled. If it is, TempMailPlusTab is instantiated; otherwise, it falls back to OneSecMailTab.
The following flowchart shows the provider selection logic:
Sources: cursor_register_manual.py:61-73
Verification Code Retrieval Flow
Once a provider is selected, the controller uses it to create an email and then fetch the verification code.
This sequence diagram shows the interactions during the verification code retrieval phase when using TempMailPlusTab.
How to Add a New Email Provider
Follow these steps to integrate a new temporary email service:
-
Create the Provider Class:
- In the
email_tabs/directory, create a new file (e.g.,my_provider_tab.py). - Inside this file, define a class that inherits from
EmailTabInterface. from email_tabs.email_tab_interface import EmailTabInterface
- In the
-
Implement Interface Methods:
- Implement the
create_email(self, timeout)method to return a new email address from your service. - Implement the
get_verification_code(self, timeout)method to poll the inbox and return the verification code.
- Implement the
-
Add Configuration (Optional):
- If your provider requires API keys or other settings, add a new section to the
default_configdictionary inconfig.py.
# In config.py inside setup_config() default_config['MyProvider'] = { 'enabled': 'false', 'api_key': '' }- Your provider class can then read these values from the config.
- If your provider requires API keys or other settings, add a new section to the
-
Integrate into
EmailController:- Modify the
get_email_servicemethod incursor_register_manual.py. - Add logic to check if your new provider is enabled in the configuration and instantiate your new class accordingly.
# In cursor_register_manual.py inside EmailController.get_email_service() from email_tabs.my_provider_tab import MyProviderTab ... if self.config.getboolean('MyProvider', 'enabled'): print("Using MyProvider service") return MyProviderTab(self.browser) ... - Modify the
Sources: config.py:30, cursor_register_manual.py:61-73, email_tabs/email_tab_interface.py
Conclusion
The email provider system in cursor-free-vip is a well-defined, modular component that simplifies the process of integrating different temporary email services. By adhering to the EmailTabInterface contract and adding the necessary configuration, developers can easily extend the application's capabilities to support a wider range of email providers, making the account registration process more robust and flexible.