Overview
This node, named "Unsubscribe," provides two main operations related to managing unsubscribe links commonly found in email content:
Extract Links from Email: It scans the provided email content and extracts URLs that likely correspond to unsubscribe or opt-out links. This is useful for automating the identification of unsubscribe links embedded in marketing or newsletter emails.
Click Unsubscribe Link: It performs an HTTP GET request on a specified unsubscribe URL, simulating clicking the link, and then gathers information about the resulting webpage such as status code, page title, and whether the page confirms successful unsubscription. This helps verify if an unsubscribe link is valid and effective.
Practical Examples
- Automatically extract all unsubscribe links from a batch of marketing emails to build a list of opt-out URLs.
- Validate unsubscribe links by programmatically visiting them and checking if the unsubscription was successful based on page content.
- Integrate with workflows that manage email subscriptions by detecting and processing unsubscribe requests automatically.
Properties
| Name | Meaning |
|---|---|
| Operation | Choose between "Click Unsubscribe Link" (visit a given unsubscribe URL) or "Extract Links from Email" (find unsubscribe-related URLs in email content). |
| Unsubscribe URL | The URL to visit when performing the "Click Unsubscribe Link" operation. |
| Email Content | The raw email content (HTML or text) to scan for unsubscribe-related links when using the "Extract Links from Email" operation. |
For the "Operation" property, the options are:
- Click Unsubscribe Link
- Extract Links from Email
Output
The node outputs JSON data with the following structure depending on the operation:
For "Extract Links from Email"
{
"success": true,
"operation": "extract_links",
"links": [
"https://example.com/unsubscribe",
"https://example.com/opt-out"
],
"totalFound": 2,
"timestamp": "2024-06-01T12:00:00.000Z"
}
links: An array of unique unsubscribe-related URLs extracted from the email content.totalFound: Number of unique links found.success: Indicates extraction succeeded.timestamp: When the extraction was performed.
For "Click Unsubscribe Link"
{
"success": true,
"operation": "click_link",
"url": "https://example.com/unsubscribe",
"result": {
"success": true,
"webpageInfo": {
"statusCode": 200,
"statusMessage": "OK",
"headers": { /* HTTP response headers */ },
"url": "https://example.com/unsubscribe",
"finalUrl": "https://example.com/unsubscribe-confirmation",
"contentType": "text/html",
"contentLength": "12345",
"title": "Unsubscribe Confirmation",
"hasUnsubscribeConfirmation": true,
"redirects": [ /* Array of redirect info objects */ ]
},
"message": "Successfully accessed unsubscribe page. Status: 200"
},
"timestamp": "2024-06-01T12:00:00.000Z"
}
url: The original unsubscribe URL requested.result.webpageInfo: Details about the HTTP response and page content.hasUnsubscribeConfirmation: Boolean indicating if the page content contains phrases suggesting successful unsubscription.message: Summary message about the request outcome.success: Indicates if the HTTP request succeeded.timestamp: When the request was made.
If the HTTP request fails, the output includes an error message and success set to false.
Dependencies
- Requires internet access to perform HTTP requests when clicking unsubscribe links.
- Uses standard HTTP headers including a custom User-Agent string identifying the request as coming from this node.
- No external API keys or credentials are required for extracting links.
- For clicking links, if the target site requires authentication, the node supports basic HTTP authentication via n8n's credential system (not detailed here).
Troubleshooting
- Missing URL or Email Content: The node throws an error if the required input (
urlfor clicking links oremailContentfor extracting links) is empty. Ensure these fields are populated. - HTTP Request Failures: Network issues, invalid URLs, or server errors can cause the "click_link" operation to fail. Check the error message returned in the output for details.
- No Links Found: If the email content does not contain recognizable unsubscribe patterns, the extracted links array will be empty.
- False Negatives in Confirmation Detection: The confirmation detection relies on matching certain keywords in the page content; some unsubscribe pages may use different wording and not be detected as confirmed.
Links and References
This summary is based solely on static analysis of the provided source code and property definitions.