Complete guide to finding and replacing mailto links across your WordPress site.
Why Replace mailto Links in WordPress
Common Problems
mailto Links in WordPress:
- Expose email to scraping bots
- Broken on iPhone Mail (iOS 26.1)
- Poor mobile experience
- No spam protection
- No tracking or analytics
Common locations:
- Theme templates (header, footer)
- Menu items
- Widget areas
- Page/post content
- Custom HTML blocks
- Email signatures in author bios
Where mailto Links Hide in WordPress
Theme Locations
1. Header
header.php- Navigation menus
- Top bar contact info
2. Footer
footer.php- Footer widgets
- Copyright/contact area
3. Sidebar
sidebar.php- Widget areas
- Contact widgets
4. Page Templates
page.php,single.php- Contact page template
- Custom templates
Content Locations
1. Navigation Menus
- Appearance → Menus
- Primary menu
- Footer menu
- Mobile menu
2. Widgets
- Appearance → Widgets
- Text widgets
- HTML widgets
- Custom widgets
3. Pages & Posts
- Contact page
- About page
- Blog posts
- Author bios
4. Custom Fields
- ACF fields
- Meta boxes
- Custom contact fields
Two Replacement Approaches
Approach 1: Manual Replace (Recommended First)
Best for:
- Small sites (< 50 pages)
- Want control over each replacement
- One-time cleanup
Steps below.
Approach 2: Auto-Replace with JavaScript (Recommended for Large Sites)
Best for:
- Large sites (hundreds of pages)
- Ongoing protection
- Set-and-forget solution
See JavaScript snippet below.
Manual Replacement Steps
Step 1: Create Your Form (5 minutes)
- Sign up at SupportRetriever
- Complete onboarding
- Set up your contact form
- Get form URL:
https://supportretriever.com/form/your-form-id - Keep it handy for replacements
Step 2: Find mailto Links (10 minutes)
Search Database
Using Search & Replace plugin:
- Install "Better Search Replace" (free plugin)
- Go to Tools → Better Search Replace
- Search for:
mailto: - Select all tables
- Don't replace yet — just search to see what you have
- Review results
Search Theme Files
- Go to Appearance → Theme Editor
- Search for
mailto:in:- header.php
- footer.php
- functions.php
- Template files
Check Menus
- Go to Appearance → Menus
- Check each menu item
- Look for "Custom Links" with mailto URLs
Check Widgets
- Go to Appearance → Widgets
- Open each widget
- Check Text/HTML widgets for mailto links
Check Content
- Use Better Search Replace to search post content
- Or use WordPress search:
mailto:in posts/pages
Step 3: Replace in Menus (5 minutes)
For navigation menu items:
- Go to Appearance → Menus
- Find menu items with mailto links
- Click to expand each item
- Replace URL with form URL:
Old: mailto:support@example.com
New: https://supportretriever.com/form/your-form-id?source=menu
- Update navigation label if needed:
Old label: support@example.com
New label: Contact Support
- Save menu
Step 4: Replace in Widgets (5 minutes)
For widget areas:
- Go to Appearance → Widgets
- Open each Text/HTML widget
- Switch to "Text" tab (not Visual)
- Find and replace:
<!-- Old -->
<a href="mailto:contact@example.com">Contact Us</a>
<!-- New -->
<a href="https://supportretriever.com/form/your-form-id?source=widget">Contact Us</a>
- Save each widget
Step 5: Replace in Theme Files (10 minutes)
For header.php:
- Go to Appearance → Theme Editor
- Open
header.php - Find mailto links
- Replace with form URL:
<!-- Old -->
<a href="mailto:<?php echo get_option('admin_email'); ?>">
Contact
</a>
<!-- New -->
<a href="https://supportretriever.com/form/your-form-id?source=header">
Contact
</a>
- Save file
For footer.php:
<!-- Old -->
<p>Email: <a href="mailto:info@example.com">info@example.com</a></p>
<!-- New -->
<p><a href="https://supportretriever.com/form/your-form-id?source=footer">Contact Us</a></p>
Note: Consider creating a child theme before editing theme files.
Step 6: Replace in Content (10 minutes)
Using Better Search Replace:
- Go to Tools → Better Search Replace
- Search for:
mailto:support@example.com - Replace with:
https://supportretriever.com/form/your-form-id?source=content - Select tables:
wp_posts,wp_postmeta - Run as dry run first
- Review what will change
- If good, run for real (uncheck "dry run")
- Run search & replace
Or manually edit pages:
- Edit each page/post with mailto links
- Switch to "Code editor" (or Text tab)
- Find and replace mailto links
- Update each page
Step 7: Replace in Custom Fields (if applicable)
If using ACF or custom fields:
- Go to Posts/Pages with custom fields
- Edit each one
- Update email fields with form URL
- Save changes
JavaScript Auto-Replace Method
When to Use This
Use JavaScript auto-replace if:
- You have hundreds of pages
- mailto links are in various places
- You want ongoing protection
- New content may have mailto links
- You don't want to hunt them all down
Installation
Method 1: Theme Footer (Simplest)
- Go to Appearance → Theme Editor
- Open
footer.php - Add before
</body>tag:
<script>
(function() {
const FORM_URL = 'https://supportretriever.com/form/your-form-id';
document.querySelectorAll('a[href^="mailto:"]').forEach(link => {
const originalHref = link.getAttribute('href');
const emailMatch = originalHref.match(/mailto:([^?]+)/);
if (emailMatch) {
link.setAttribute('href', FORM_URL + '?source=autoconvert');
link.setAttribute('data-original-email', emailMatch[1]);
}
});
})();
</script>
- Save file
Method 2: Code Snippets Plugin (Recommended)
- Install Code Snippets plugin (free)
- Go to Snippets → Add New
- Title: "Replace mailto Links"
- Paste this code:
add_action('wp_footer', function() {
?>
<script>
(function() {
const FORM_URL = 'https://supportretriever.com/form/your-form-id';
document.querySelectorAll('a[href^="mailto:"]').forEach(link => {
const originalHref = link.getAttribute('href');
const emailMatch = originalHref.match(/mailto:([^?]+)/);
if (emailMatch) {
link.setAttribute('href', FORM_URL + '?source=autoconvert');
link.setAttribute('data-original-email', emailMatch[1]);
}
});
})();
</script>
<?php
});
- Check "Only run in frontend"
- Save and activate snippet
Method 3: functions.php
Only if you're using a child theme:
- Open child theme's
functions.php - Add this code:
function replace_mailto_links() {
?>
<script>
(function() {
const FORM_URL = 'https://supportretriever.com/form/your-form-id';
document.querySelectorAll('a[href^="mailto:"]').forEach(link => {
const originalHref = link.getAttribute('href');
const emailMatch = originalHref.match(/mailto:([^?]+)/);
if (emailMatch) {
link.setAttribute('href', FORM_URL + '?source=autoconvert');
link.setAttribute('data-original-email', emailMatch[1]);
}
});
})();
</script>
<?php
}
add_action('wp_footer', 'replace_mailto_links');
- Save file
Test the JavaScript Method
- Visit your site
- Right-click a former mailto link
- Inspect element
- Verify
hrefnow points to form - Click link to test
- Verify form opens
Why "Encoding Plugins" Exist (And When Replacing is Better)
Email Encoding/Obfuscation Plugins
Popular plugins:
- Email Address Encoder
- Email Obfuscator
- Hide My Email
What they do:
- Encode email addresses using JavaScript
- Attempt to hide from bots
- Keep mailto functionality
Example encoding:
// Instead of: support@example.com
// Becomes: support@...
When Encoding is Better
Use encoding plugins if:
- You MUST display actual email address
- Users need to copy-paste email
- You can't use a contact form
- Your situation requires visible email
When Replacing is Better (Most Cases)
Replace with form if:
- You want maximum spam protection (99% vs 30%)
- Mobile experience matters (iOS 26.1 issue)
- You want conversation management
- You want analytics
- You want long-term solution
Replacement advantages over encoding:
| Feature | Encoding Plugin | Form Replacement |
|---|---|---|
| Spam protection | 30-40% | 99%+ |
| Mobile reliability | Poor | Excellent |
| iOS 26.1 compatible | No | Yes |
| Accessibility | Medium | Excellent |
| User experience | Medium | Better |
| Long-term effectiveness | Degrades | Permanent |
| Conversation management | No | Yes |
| Analytics | No | Yes |
Verdict: For most websites, replacing with forms provides better protection and user experience than encoding.
Step-by-Step with Screenshots
Visual Guide
Since we're avoiding screenshots, here's a detailed text walkthrough:
Navigation Path:
Finding mailto in Menu:
WordPress Admin → Appearance → Menus →
Select menu → Expand menu item →
Look at URL field → Replace if contains "mailto:"
Finding mailto in Widgets:
WordPress Admin → Appearance → Widgets →
Click widget to expand → Switch to Text tab →
Find mailto: in HTML → Replace with form URL
Finding mailto in Theme:
WordPress Admin → Appearance → Theme Editor →
Select header.php or footer.php →
Search page for "mailto:" → Replace each instance →
Click "Update File"
Using Better Search Replace:
WordPress Admin → Tools → Better Search Replace →
"Search for" field: mailto:youremail@example.com →
"Replace with" field: https://supportretriever.com/form/your-id →
Select tables: wp_posts →
Check "Run as dry run" → Click "Run Search/Replace" →
Review results → Uncheck dry run → Run again for real
Verification Checklist
After Replacement
- Visit homepage — check footer/header links
- Check contact page — verify no mailto links
- Check navigation menus — all items work
- Check sidebar widgets — form links work
- View source code — search for "mailto:" (should find none)
- Test on mobile device — verify links open form
- Test on iPhone — verify iOS 26.1 fix works
- Submit test message — verify delivery
- Check email notification — verify receipt
Testing Commands
Search remaining mailto links:
- View page source (Ctrl+U / Cmd+U)
- Search for "mailto:" (Ctrl+F / Cmd+F)
- Should find: 0 results
- If you find any, note location and replace
Test form links:
- Click each contact link
- Verify form opens
- Fill out test submission
- Verify email arrives
- Repeat on mobile
Troubleshooting
"I still see mailto links"
Possible causes:
- Cached pages (clear cache)
- CDN cache (clear CDN)
- Browser cache (hard refresh: Ctrl+Shift+R)
- Missed locations (check all sources)
Solutions:
- Clear all caches
- Use incognito/private browsing
- Review all locations again
"JavaScript method isn't working"
Possible causes:
- JavaScript error
- Script loading order
- Conflicting plugins
Debug:
- Open browser console (F12)
- Look for errors
- Verify script is loaded
- Check if jQuery conflict
Solutions:
- Wrap in
jQuery(document).ready() - Load script in footer (not header)
- Disable plugins one by one to find conflict
"Form URL is wrong"
Fix:
- Go to SupportRetriever dashboard
- Navigate to Form Management
- Copy correct form URL
- Update all instances
- Clear cache
WordPress Multisite
Network-Wide Replacement
If you have multisite:
- Use Better Search Replace on network database
- Or run script on each subsite
- Or add JavaScript to network theme
Considerations:
- Different sites may need different forms
- Use metadata to track which site:
?site=site1 - Consider central form or separate forms per site
