Creating a Bookmarklet That Emails the Current URL
One-click bookmarklet that captures the current page URL and title, sends it to a PayloadRelay endpoint, and delivers it to your email inbox.
Create a browser bookmarklet that sends the current page's URL and title to your email with a single click. Useful for saving articles, sharing links, or building a personal read-later list.
Purpose
This guide helps you:
- Build a JavaScript bookmarklet that calls a PayloadRelay endpoint.
- Configure an email target to receive saved URLs.
- Add optional notes and tags to saved links.
- Install the bookmarklet in any browser.
Prerequisites and permissions
- A PayloadRelay endpoint configured to accept
POSTwithJSONpayload format. - A confirmed email target attached to the endpoint.
- Note: Bookmarklets using
fetch()require CORS to be enabled on the endpoint. If you get CORS errors, either add your domain to the endpoint's allowed CORS origins, or use the GET/image-pixel fallback shown in step 7.
Step-by-step workflow
1. Create the endpoint
- Open
Endpointsand selectCreate endpoint. - Set the accepted method to
POST. - Set payload format to
JSON. - In
Target destinations, attach your confirmed email target. - Save and copy the endpoint URL.
2. Basic bookmarklet
This bookmarklet sends the current page URL and title to your PayloadRelay endpoint:
javascript:void(fetch('https://api.payloadrelay.com/relay/YOUR_ENDPOINT_ID',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({subject:'Saved Link: '+document.title,url:location.href,title:document.title,saved_at:new Date().toISOString()})}).then(()=>alert('Link saved!')).catch(()=>alert('Failed to save link')))Readable version:
javascript:void(
fetch('https://api.payloadrelay.com/relay/YOUR_ENDPOINT_ID', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
subject: 'Saved Link: ' + document.title,
url: location.href,
title: document.title,
saved_at: new Date().toISOString()
})
})
.then(() => alert('Link saved!'))
.catch(() => alert('Failed to save link'))
)3. Bookmarklet with notes
This version prompts for an optional note before sending:
javascript:void((function(){var n=prompt('Add a note (optional):','');if(n!==null){fetch('https://api.payloadrelay.com/relay/YOUR_ENDPOINT_ID',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({subject:'Saved Link: '+document.title,url:location.href,title:document.title,note:n||'(no note)',saved_at:new Date().toISOString()})}).then(function(){alert('Link saved!')}).catch(function(){alert('Failed to save link')})}})())Readable version:
javascript:void((function() {
var note = prompt('Add a note (optional):', '');
if (note !== null) {
fetch('https://api.payloadrelay.com/relay/YOUR_ENDPOINT_ID', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
subject: 'Saved Link: ' + document.title,
url: location.href,
title: document.title,
note: note || '(no note)',
saved_at: new Date().toISOString()
})
})
.then(function() { alert('Link saved!'); })
.catch(function() { alert('Failed to save link'); });
}
})())Pressing Cancel on the prompt aborts the save.
4. Bookmarklet with tags
Add tag selection for categorizing saved links:
javascript:void((function(){var t=prompt('Tags (comma-separated):','reading');if(t!==null){var n=prompt('Note (optional):','');if(n!==null){fetch('https://api.payloadrelay.com/relay/YOUR_ENDPOINT_ID',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({subject:'['+t+'] '+document.title,url:location.href,title:document.title,tags:t,note:n||'(no note)',saved_at:new Date().toISOString()})}).then(function(){alert('Link saved!')}).catch(function(){alert('Failed to save link')})}}})())The email subject line will include the tags: [reading, tech] Article Title.
5. Install the bookmarklet
Chrome, Edge, Firefox, Brave
- Show the bookmarks bar (
Ctrl+Shift+B/Cmd+Shift+B). - Right-click the bookmarks bar →
Add page/Add bookmark. - Set the name to something recognizable (e.g.
📧 Save Link). - Paste the bookmarklet code (starting with
javascript:) into the URL field. - Save.
Safari
- Go to
Bookmarks→Add Bookmarkfor any page. - Edit the bookmark: right-click →
Edit Address. - Replace the URL with the bookmarklet code.
- Save.
Mobile (iOS Safari)
- Bookmark any page.
- Edit the bookmark and replace the URL with the bookmarklet code.
- To use it, start typing the bookmark name in the address bar and tap it from suggestions.
6. Configure the email target
- Open
Relay targets→Add target→Email. - Enter the email address where saved links should arrive.
- Confirm the email target.
- Attach it to the bookmarklet endpoint.
Each click of the bookmarklet sends an email with:
- Subject:
Saved Link: <page title>(or with tags if configured) - Body fields: URL, title, note, tags, timestamp
7. Handling CORS restrictions
Some websites have strict Content Security Policies that block fetch() to external URLs. If the bookmarklet fails silently on certain sites, use an image-pixel fallback approach:
javascript:void((function(){var d=encodeURIComponent(JSON.stringify({subject:'Saved: '+document.title,url:location.href,title:document.title,saved_at:new Date().toISOString()}));new Image().src='https://api.payloadrelay.com/relay/YOUR_ENDPOINT_ID?data='+d;alert('Link saved!')})())This requires the endpoint to accept GET requests with query parameters. Note that GET query strings have length limits, so this approach works best for shorter payloads.
Expected result and verification checks
- Clicking the bookmarklet shows a success alert.
- Email arrives within seconds with the page URL, title, and optional note/tags.
- Requests appear in PayloadRelay
Request activitywith outcomeACCEPTED.
Common issues and fixes
- Bookmarklet does nothing: ensure the URL field starts with
javascript:and contains no line breaks. Failed to save linkalert: check browser console for errors. The most common cause is Content Security Policy blocking the fetch.- No email received: verify the email target is
Confirmedand attached to the endpoint. - CORS errors in console: use the GET/image-pixel fallback for sites with strict CSP.
- Prompt not appearing: some browsers block prompts from bookmarklets on certain pages — the basic version (without prompts) will still work.